python - 估计器管道的无效参数 rf
问题描述
我将 RandomForestRegressor 与 GridSearchCV 一起使用。我收到此错误:
ValueError: Invalid parameter RandomForestRegressor for estimator Pipeline
我不明白为什么。这是我的代码:
pipelines = {
'rf': make_pipeline(StandardScaler(),
RandomForestRegressor(random_state=42)),
rf_hyperparameters = {
'RandomForestRegressor__n_estimators': [100, 200, 300, 400, 500],
'RandomForestRegressor__max_features': ['auto', 'sqrt', 0.33]
}
hyperparameters = {
'rf': rf_hyperparameters,
}
fitted_alternative_models = {}
for name, pipeline in pipelines.items():
alt_model = GridSearchCV(pipeline, hyperparameters[name], cv=10, n_jobs=-1)
alt_model.fit(X_train, y_train.values.ravel())
谢谢!
解决方案
我变了:
rf_hyperparameters = {
'RandomForestRegressor__n_estimators': [100, 200, 300, 400, 500],
'RandomForestRegressor__max_features': ['auto', 'sqrt', 0.33]
}
至:
rf_hyperparameters = {
'randomforestregressor__n_estimators': [100, 200, 300, 400, 500],
'randomforestregressor__max_features': ['auto', 'sqrt', 0.33]
}
它正在工作。
推荐阅读
- java - 无法使用 NetBeans 打开新项目或文件
- ibm-cloud - 如何从 IIB 迁移到 AppConnect
- sql-server - 从查询结果更新多个表
- azure - 处理扩展 AzureDiskEncryption 时 VM 报告失败
- keras - 在每一层可视化 Keras CNN 最终训练的过滤器
- android - 如何将当前位置添加到我的地图活动中?
- java - Java ArchUnit:检测 getMethodCallsFromSelf 方法上的注释
- dart - 引发了另一个异常:FormatException: Invalid character (at character 6)
- php - 如何从数组中删除 nbsp 元素
- reactjs - 将 React 应用程序的生产版本部署到 Google App Engine:Service Worker 注册失败