Skip to content

[Class] FeatureExtractor 📦

João Saraiva edited this page Jun 9, 2022 · 1 revision

A Feature Extractor is a Pipeline Unit. Meaning, you can instantiate one and include it in a Pipeline.

How to instantiate

Give a tuple of functions that compute features of an array of samples. You can create your own functions and pass them, or you can reference some of the most popular ones, like:

  • TimeFeatures.mean
  • TimeFeatures.variance
  • TimeFeatures.deviation
  • Etc.

You may also name the Feature Extractor:

extractor = FeatureExtractor((TimeFeatures.mean, TimeFeatures.variance ...), name = 'My first feature extractor')

What's a feature function ⨐ ?

It's any function that receives an array floats, computes what it should from them, and returns one float -- the computed feature. You just have to define them and pass them to the initializer:

Example

def my_feature_1(samples:np.array) -> float:
    # TODO Do your thing and return the computed feature


extractor = FeatureExtractor((my_feature_1, TimeFeatures.variance, ...), 

How to use it

In a Pipeline

Add it to a Pipeline:

pipeline.add(extractor)

Independently

Or apply it directly to a Timeseries that is equally equally segmented:

features = extractor.apply(timeseries1)

A feature will be computed for every segment and a Features object will be returned, from which you can obtain the computed features by indexing ([]) operations:

average_timeseries = features['mean']