Feature Functions¶
This module has functions or callable objects that can be used to compute features from segmented time series data
Sets of these functions or callables can be passed in a dictionary object to initialize the
FeatureRep
transformer.
All functions follow the same template and process a single segmented time series instance:
>>> def compute_feature(X): >>> F = np.mean(X, axis = 1) >>> return F X : array-like shape [n_segments, segment_width, n_variables] F : array-like [n_segments, n_features] The number of features returned (n_features) must be >= 1Note
np.atleast_3d
is used if accessing the third dimension, as some datasets willhave only a single time series variable. See
hist4
as an example.
See hist for an example of a callable object
Examples¶
>>> from seglearn.feature_functions import all_features
>>> from seglearn.transform import FeatureRep
>>> FeatureTransform = FeatureRep(features=all_features())
-
seglearn.feature_functions.
all_features
()[source]¶ Returns dictionary of all features in the module
Note
Some of the features (hist4, corr) are relatively expensive to compute
-
seglearn.feature_functions.
base_features
()[source]¶ Returns dictionary of some basic features that can be calculated for segmented time series data
-
seglearn.feature_functions.
corr2
(X)[source]¶ computes correlations between all variable pairs in a segmented time series
Note
this feature is expensive to compute with the current implementation, and cannot be
used with univariate time series
-
seglearn.feature_functions.
emg_features
(threshold=0)[source]¶ Return a dictionary of popular features used for EMG time series classification.
-
seglearn.feature_functions.
emg_var
(X)[source]¶ variance (assuming a mean of zero) for each variable in the segmented time series (equals abs_energy divided by (seg_size - 1))
-
class
seglearn.feature_functions.
hist
(bins=4)[source]¶ histogram for each variable in a segmented time series
Note
this feature is expensive to compute with the current implementation
Methods
__call__
(self, X)Call self as a function.
-
seglearn.feature_functions.
hudgins_features
(threshold=0)[source]¶ Return a dict of Hudgin’s time domain features used for EMG time series classification.
-
seglearn.feature_functions.
maximum
(X)[source]¶ maximum value for each variable in a segmented time series
-
seglearn.feature_functions.
mean
(X)[source]¶ statistical mean for each variable in a segmented time series
-
seglearn.feature_functions.
mean_abs
(X)[source]¶ statistical mean of the absolute values for each variable in a segmented time series
-
seglearn.feature_functions.
mean_crossings
(X)[source]¶ Computes number of mean crossings for each variable in a segmented time series
-
seglearn.feature_functions.
median
(X)[source]¶ statistical median for each variable in a segmented time series
-
seglearn.feature_functions.
median_absolute_deviation
(X)[source]¶ median absolute deviation for each variable in a segmented time series
-
seglearn.feature_functions.
minimum
(X)[source]¶ minimum value for each variable in a segmented time series
-
seglearn.feature_functions.
mse
(X)[source]¶ computes mean spectral energy for each variable in a segmented time series
-
seglearn.feature_functions.
root_mean_square
(X)[source]¶ root mean square for each variable in the segmented time series
-
class
seglearn.feature_functions.
slope_sign_changes
(threshold=0)[source]¶ number of changes between positive and negative slope among three consecutive samples above a certain threshold for each variable in the segmented time series
Methods
__call__
(self, X)Call self as a function.
-
seglearn.feature_functions.
std
(X)[source]¶ statistical standard deviation for each variable in a segmented time series
-
seglearn.feature_functions.
var
(X)[source]¶ statistical variance for each variable in a segmented time series
-
seglearn.feature_functions.
waveform_length
(X)[source]¶ cumulative length of the waveform over a segment for each variable in the segmented time series