任何人都可以检查以下代码的问题吗?我在构建模型的任何步骤中都错了吗?我已经在参数中添加了两个“clf__”。
clf=RandomForestClassifier()
pca = PCA()
pca_clf = make_pipeline(pca, clf)
kfold = KFold(n_splits=10, random_state=22)
parameters = {'clf__n_estimators': [4, 6, 9], 'clf__max_features': ['log2',
'sqrt','auto'],'clf__criterion': ['entropy', 'gini'], 'clf__max_depth': [2,
3, 5, 10], 'clf__min_samples_split': [2, 3, 5],
'clf__min_samples_leaf': [1,5,8] }
grid_RF=GridSearchCV(pca_clf,param_grid=parameters,
scoring='accuracy',cv=kfold)
grid_RF = grid_RF.fit(X_train, y_train)
clf = grid_RF.best_estimator_
clf.fit(X_train, y_train)
grid_RF.best_score_
cv_result = cross_val_score(clf,X_train,y_train, cv = kfold,scoring =
"accuracy")
cv_result.mean()
Run Code Online (Sandbox Code Playgroud)