Features¶
Feature extractors are used, as the name suggests, to extract features from a signal. AutonFeat
provides a wide range of feature extractors that can be used to extract features from a signal. The following sections describe the various feature extractors that are available in AutonFeat
.
Domain Agnostic¶
Domain agnostic features are applicable to most signals irrespective of the domain.
Summary Statistics¶
Feature | Description | Endpoint |
---|---|---|
Max | Maximum value of the signal | MaxTransform |
Min | Minimum value of the signal | MinTransform |
Mean | Mean of the signal | MeanTransform |
Median | Median of the signal | MedianTransform |
Standard Deviation | Standard deviation of the signal | StdTransform |
Variance | Variance of the signal | VarTransform |
Quantile | Quantile of the signal | QuantileTransform |
Range | Range of the signal | RangeTransform |
IQR | Interquartile range of the signal | IQRTransform |
N Valid | Number of valid values in the signal | NValidTransform |
Skewness | Skewness of the signal | SkewnessTransform |
Kurtosis | Kurtosis of the signal | KurtosisTransform |
Data Sparsity Measures¶
Feature | Description | Endpoint |
---|---|---|
Data Density | Ratio of valid values to window size | DataDensityTransform |
Data Sparsity | Ratio of missing values to window size | DataSparsityTransform |
Information Theoretic Measures¶
Feature | Description | Endpoint |
---|---|---|
Shannon Entropy | Shannon entropy of the signal | EntropyTransform |
KL Divergence | KL divergence of the signal with another distribution | EntropyTransform |
Sample Entropy | Sample entropy of the signal | SampleEntropyTransform |
Approximate Entropy | Approximate entropy of the signal | ApproxEntropyTransform |
Cross Entropy | Cross entropy of the signal with another distribution | CrossEntropyTransform |
Domain Specific¶
Domain expertise almost always helps in extracting better features. AutonFeat
provides a wide range of domain specific features that can be used to extract features from a signal. The following sections describe the various domain specific feature extractors that are available in AutonFeat
.
Biomedical, and Physiological Signals¶
(Coming Soon)
Feature | Description | Endpoint |
---|---|---|
Functional Form¶
A functional form for each of the transforms above is also provided for convenience. Check out the autonfeat.functional
sub-module for more details.
Custom Featurizers¶
It is possible to design custom features while extending the functionality of AutonFeat
. The Transform
class is an abstraction representing a featurizer. When defining a custom featurizer, one can utilize the efficiency of the SlidingWindow
abstraction by inhering defining the featurizer to inherit from Transform
. The following example demonstrates how to create a custom feature that computes the mean of the signal.
import numpy as np
from typing import Callable, Union
from autonfeat.core import Transform
class MeanTransform(Transform):
def __init__(self, name: str = "Mean") -> None:
super().__init__(name=name)
def __call__(self, signal_window: np.ndarray, where: Callable[[Union[int, float, np.int_, np.float_]], Union[bool, np.bool_]] = lambda x: not np.isnan(x)) -> Union[np.float_, np.int_]:
where_fn = np.vectorize(pyfunc=where)
return np.mean(x, where=where_fn(x))
This can then be passed as the featurizer to be applied at every sliding window interval as such -
import autonfeat as aft
# Random data
n_samples = 100
x = np.random.rand(n_samples)
# Create sliding window
ws = 10
ss = 10
window = aft.SlidingWindow(window_size=ws, step_size=ss)
# Create transform
tf = MeanTransform()
# Get featurizer
featurizer = window.use(tf)
# Get features
features = featurizer(x)
# Print features
print(window)
print(tf)
print(features)
See this for more examples on how to use feature extractors in AutonFeat
.
If you enjoy using AutonFeat
, please consider starring the repository ⭐️.