June 2018
Intermediate to advanced
276 pages
6h 26m
English
The tree-based feature selection method is used to check and compute feature importance. The following is an example of how we can use the tree-based feature selection technique delivered by the official scikit-learn documentation:
>>> from sklearn.ensemble import ExtraTreesClassifier>>> from sklearn.datasets import load_iris>>> from sklearn.feature_selection import SelectFromModel>>> iris = load_iris()>>> X, y = iris.data, iris.target>>> X.shape>>> clf = ExtraTreesClassifier()>>> clf = clf.fit(X, y)>>> clf.feature_importances_ >>> model = SelectFromModel(clf, prefit=True)>>> X_new = model.transform(X)>>> X_new.shape
As I said previously, feature selection is used in the pre-processing phase, so you can use ...
Read now
Unlock full access