我正在尝试运行 RFECV 来选择最佳功能,并运行 GridSearchCV 来获得最佳超参数。我的代码如下所示:
params = {'estimator__C': [1e-4, 1e4]}
estimator = LogisticRegression(random_state=123)
selector = RFECV(estimator, step=1, cv=5, scoring='recall')
clf = GridSearchCV(selector, params, cv=5)
clf.fit(X_train, y_train)
当我在 GridSearchCV 中包含相同的评分指标时,我会从 cv_results 中获得不同的最佳特征、n_features 和参数。为什么会发生这种情况,哪些方法是正确的?
params = {'estimator__C': [1e-4, 1e4]}
estimator = LogisticRegression(random_state=123)
selector = RFECV(estimator, step=1, cv=5, scoring='recall')
clf = GridSearchCV(selector, params, cv=5, scoring='recall')
clf.fit(X_train, y_train)