ITMO_FS.wrappers.deterministic
.AddDelWrapper¶
-
class
ITMO_FS.wrappers.deterministic.
AddDelWrapper
(estimator, score, maximize=True, seed=42)¶ Creates add-del feature wrapper
Parameters: - estimator (object) – A supervised learning estimator with a fit method
- score (boolean) – A callable function which will be used to estimate score
- score – maximize = True if bigger values are better for score function
- seed (int) – Seed for python random
- best_score (float) – The best score of given metric on the feature combination after add-del procedure
See also
Lecture
,p.13
Examples
>>> from sklearn.metrics import accuracy_score >>> from sklearn import datasets,linear_model >>> data = datasets.make_classification(n_samples=1000, n_features=20) >>> X = np.array(data[0]) >>> y = np.array(data[1]) >>> lg = linear_model.LogisticRegression(solver='lbfgs') >>> add_del = AddDelWrapper(lg, accuracy_score) >>> add_del.fit(X, y)
>>> from sklearn.metrics import mean_absolute_error >>> boston = datasets.load_boston() >>> X = boston['data'] >>> y = boston['target'] >>> lasso = linear_model.Lasso() >>> add_del = AddDelWrapper(lasso, mean_absolute_error, maximize=False) >>> add_del.fit(X, y)
-
__init__
(estimator, score, maximize=True, seed=42)¶ Initialize self. See help(type(self)) for accurate signature.
-
fit
(X, y, cv=3, silent=True)¶ Fits wrapper.
Parameters: - X (numpy array or pandas DataFrame, shape (n_samples, n_features)) – The training input samples.
- y (numpy array of pandas Series, shape (n_samples, )) – The target values.
- cv=3 (int) – Number of splits in cross-validation
- silent=True (boolean) – If silent=False then prints all the scores during add-del procedure
- Returns –
- ---------- –
- features (list) – List of feature after add-del procedure
Examples
Parameters: - silent –
- y –
- X –
- cv –