pyeeg.features.FeatureReducer
- class pyeeg.features.FeatureReducer(config: ReductionConfig)
Reduce the dimensionality of feature sets.
Provides a scikit-learn-like interface for reducing 2D feature matrices (samples x features) to a lower-dimensional space. The reduction behavior is governed by the
methodfield of the configuration:"pca": principal component analysis. Components are the principal eigenvectors of the feature covariance, sorted by descending eigenvalue; the number retained isn_componentsor is derived fromvariance_threshold."ica": independent component analysis implemented as a whitening transform of the centered data. The number retained isn_componentsor the full input dimensionality."none": identity transformation; features pass through unchanged.
Data is centered (mean subtracted per feature) before reduction, and the fitted mean is added back by
inverse_transform().- Parameters:
config (ReductionConfig) – Configuration of the reduction method and component selection.
- config
Configuration of the reducer.
- Type:
- _components
Fitted component matrix (rows are components), or
Nonebefore fit / formethod='none'.- Type:
ndarray or None
- _explained_variance
Per-component explained variance ratios (PCA only), or
Noneotherwise.- Type:
ndarray or None
- _mean
Per-feature mean used to center the data, or
Nonebefore fit.- Type:
ndarray or None
Methods
FeatureReducer.fit(features)Fit the reducer to the features.
FeatureReducer.fit_transform(features)Fit the reducer and transform the features.
Return the fitted components.
Return the per-component explained variance ratios.
Return the number of retained components.
Transform reduced features back to original space.
FeatureReducer.transform(features)Transform features to reduced space.