【发布时间】:2019-05-06 11:46:12
【问题描述】:
我正在尝试对随机森林分类器进行网格搜索,我正在尝试测试不同的 PCA 组件和 n_estimators
model_rf = RandomForestClassifier()
pca_rf = Pipeline([('pca', PCA()), ('rf', RandomForestClassifier())])
param_grid_rf = [{
'pca__n_components': [20],
'rf__n_estimators': [5]
}]
grid_cv_rf = GridSearchCV(estimator=pca_rf, cv=5,param_grid=param_grid_rf)
grid_cv_rf.fit(x_train, y_train1)
test_pca_evaluate = pca.transform(x_test)
y_pred = model_rf.predict(test_pca_evaluate)#error here
在最后一行中,我收到一条错误消息“尚未安装此 RandomForestClassifier 实例。在使用此方法之前,请使用适当的参数调用 'fit'。”
【问题讨论】:
标签: machine-learning scikit-learn random-forest grid-search