SRSelector#
- class chemotools.feature_selection.SRSelector(model, threshold: float = 1.0)[ソース]
ベースクラス:
_PLSFeatureSelectorBaseThis selector is used to select features that contribute significantly to the latent variables in a PLS regression model using the Selectivity Ratio (SR) method.
- パラメータ:
model (Union[_PLS, Pipeline]) -- The PLS regression model or a pipeline with a PLS regression model as last step.
threshold (float, default=1.0) -- The threshold for feature selection. Features with importance above this threshold will be selected.
- 変数:
estimator (ModelTypes) -- The fitted model of type _BasePCA or _PLS
feature_scores (np.ndarray) -- The calculated feature scores based on the selected method.
support_mask (np.ndarray) -- The boolean mask indicating which features are selected.
参照
- [1] Kim H. Esbensen,
"Multivariate Data Analysis - In Practice", 5th Edition, 2002.
サンプル
>>> from chemotools.datasets import load_fermentation_train >>> from chemotools.feature_selection import SRSelector >>> from sklearn.cross_decomposition import PLSRegression >>> # Load sample data >>> X, y = load_fermentation_train() >>> # Instantiate the PLS regression model >>> pls_model = PLSRegression(n_components=2).fit(X, y) >>> # Instantiate the SR selector with the PLS model >>> selector = SRSelector(model=pls_model, threshold=0.9) >>> selector.fit(X) SRSelector(model=PLSRegression(n_components=2), threshold=0.9) >>> # Get the selected features >>> X_selected = selector.transform(X) >>> X_selected.shape (21, 978)
Attributes
estimator_- fit(X: ndarray, y=None) SRSelector[ソース]
Fit the transformer to calculate the feature scores and the support mask.
- パラメータ:
X (array-like of shape (n_samples, n_features)) -- The input data to fit the transformer to.
y (None) -- Ignored to align with API.
- 戻り値:
self -- The fitted transformer.
- 戻り値の型:
SRSelector