feature_vector

Module: resources.data_types.feature_vector

Extend array of feature values with some additional properties

Inheritance diagram for pySPACE.resources.data_types.feature_vector:

Inheritance diagram of pySPACE.resources.data_types.feature_vector

FeatureVector

class pySPACE.resources.data_types.feature_vector.FeatureVector[source]

Bases: pySPACE.resources.data_types.base.BaseData

Represent a feature vector (including meta information)

This type is collected as FeatureVectorDataset. This type of dataset can be also used to create sets from FeatureVectors, e.g., from csv files. For data access in a node chain, data is loaded with the FeatureVectorSourceNode as first node and saved with a FeatureVectorSinkNode as the last node. For creating feature vectors from TimeSeries objects in a processing chain, the nodes in the feature_generation module can be used.

For historical reasons, the FeatureVector object is a 2d array where the first axes is not actively used.

When creating a feature vector, the first mandatory argument with the data (input_array) can be any object, which can be cast to a two dimensional array, including lists and one-dimensional arrays.

The second (recommended) argument are the feature_names. This is a list of strings which becomes an additional property of the feature vector class. For the MNIST dataset, feature names like Pixel001 are used. For mappings between feature vectors and TimeSeries objects, certain naming conventions should be met. The name parts should be separated with an underscore. The first part denotes an abbreviation of the feature type. The second part denotes the sensor/channel, the data was taken from. The third part is an information on the time part in seconds. the feature was taken from. An example of such a feature name is TD_C3_0.080sec.

If no feature names are given, the default name is feature_INDEX_0.000sec where INDEX is replaced by the respective index of the feature in the data array.

Note

For memory issues, the feature_names are hashed and not stored individually for every samples.

Additionally, a FeatureVector comes with the metadata from its base type.

For accessing the array only without the meta information, please use the command

x = data.view(numpy.ndarray)

which hides this information. This is especially necessary, if you do not want to forward certain information. For example the feature names will not make any sense, when accessing only a subpart of the array.

Author:Jan Hendrik Metzen (jhm@informatik.uni-bremen.de)
Created:2009/01/30

Class Components Summary

__array_finalize__(obj) Inherit feature names from obj
__eq__(other) Test for same type, dimensions, features names, and array values
__new__(subtype, input_array[, ...]) Create FeatureVector object
__reduce__()
__setstate__(state)
__str__() Connect array values and feature names for a good string representation
del_feature_names() Nothing happens, when feature names are deleted
feature_names Property feature_names of FeatureVector.
feature_names_dict
get_feature_names() Extract feature names from hash
replace_data(old, data, \*\*kwargs) Create new feature vector with the given data but the old metadata
set_feature_names(feature_names) Set feature names, using the hash and store hash if needed
static __new__(subtype, input_array, feature_names=None, tag=None)[source]

Create FeatureVector object

Refer to general class documentation.

__array_finalize__(obj)[source]

Inherit feature names from obj

__str__()[source]

Connect array values and feature names for a good string representation

__reduce__()[source]
__setstate__(state)[source]
feature_names_dict = {8022900588917907210: ['TD_S1_0sec', 'TD_S2_1sec']}
get_feature_names()[source]

Extract feature names from hash

set_feature_names(feature_names)[source]

Set feature names, using the hash and store hash if needed

del_feature_names()[source]

Nothing happens, when feature names are deleted

feature_names

Property feature_names of FeatureVector.

static replace_data(old, data, **kwargs)[source]

Create new feature vector with the given data but the old metadata

A factory method which creates a feature vector object with the given data and the metadata from the old feature vector

__eq__(other)[source]

Test for same type, dimensions, features names, and array values