LoslegenKostenlos loslegen

Ensemble models for extra votes

The LassoCV() model selected 22 out of 32 features. Not bad, but not a spectacular dimensionality reduction either. Let's use two more models to select the 10 features they consider most important using the Recursive Feature Eliminator (RFE).

The standardized training and test data has been pre-loaded for you as X_train, X_test, y_train, and y_test.

Diese Übung ist Teil des Kurses

Dimensionality Reduction in Python

Kurs anzeigen

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

from sklearn.feature_selection import RFE
from sklearn.ensemble import GradientBoostingRegressor

# Select 10 features with RFE on a GradientBoostingRegressor, drop 3 features on each step
rfe_gb = RFE(estimator=____, 
             n_features_to_select=____, step=____, verbose=1)
rfe_gb.fit(X_train, y_train)
Code bearbeiten und ausführen