Closed
Description
Describe the bug
I'm using the scikit-learn version 1.3.0. When I use
rfecv = RFECV(....) rfecv.fit(X, y) print(rfecv.cv_results_)
that code gives me a traceback: KeyError: 'n_features'
I seen that key in the doc.
Steps/Code to Reproduce
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import StratifiedKFold
from sklearn.feature_selection import RFECV
X, y = load_iris(return_X_y=True)
model = RandomForestClassifier(random_state=42)
cv = StratifiedKFold(n_splits=5)
rfecv = RFECV(
estimator=model,
step=8,
cv=cv,
scoring='accuracy',
n_jobs=-1,
verbose=10
)
rfecv.fit(X, y)
print(rfecv.cv_results_["n_features"])
print(rfecv.n_features_)
Expected Results
It should have the key.
Actual Results
print(rfecv.cv_results_["n_features"])
KeyError: 'n_features'
Versions
1.3.0