ITMO_FS.wrappers.deterministic
.SequentialForwardSelection¶
-
class
ITMO_FS.wrappers.deterministic.
SequentialForwardSelection
(estimator, n_features, measure)¶ Sequentially Adds Features that Maximises the Classifying function when combined with the features already used TODO add theory about this method
Parameters: - estimator (object) – A supervised learning estimator with a fit method that provides information about feature importance either through a coef_ attribute or through a feature_importances_ attribute.
- n_features (int) – Number of features to select.
- measure (string or callable) – A standard estimator metric (e.g. ‘f1’ or ‘roc_auc’) or a callable object / function with signature measure(estimator, X, y) which should return only a single value.
Examples
-
__init__
(estimator, n_features, measure)¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(X, y, cv=3)¶ Fits wrapper.
Parameters: - X (array-like, shape (n_features,n_samples)) – The training input samples.
- y (array-like, shape (n_features,n_samples)) – The target values.
- cv (int) – Number of folds in cross-validation.
Returns: Return type: None
Examples
>>> from ITMO_FS.wrappers import SequentialForwardSelection >>> from sklearn.linear_model import LogisticRegression >>> from sklearn.datasets import make_classification >>> import numpy as np >>> dataset = make_classification(n_samples=100, n_features=20, n_informative=4, n_redundant=0, shuffle=False) >>> data, target = np.array(dataset[0]), np.array(dataset[1]) >>> model = SequentialForwardSelection(LogisticRegression(), 5, 'f1_macro') >>> model.fit(data, target) >>> print(model.selected_features)