python - 错误:AttributeError:“GridSearchCV”对象没有属性“staged_predict”
问题描述
这是估算器的声明:
from sklearn.model_selection import GridSearchCV
param_grid = {'learning_rate': [0.1],
'max_depth': [4],
'min_samples_leaf': [3],
'max_features': [1.0]
}
est = GridSearchCV(ensemble.GradientBoostingRegressor(n_estimators=100),
param_grid, n_jobs=4, refit=True)
est.fit(X_train, y_train)
best_params = est.best_params_
%%time
est = ensemble.GradientBoostingRegressor(n_estimators=500).fit(X_train, y_train)
运行之后,当我运行以下代码时出现错误
Iterations = 2000
# compute test set deviance
test_score = np.zeros((Iterations,), dtype=np.float64)
for i, y_pred in enumerate(est.staged_predict(X_test)):
test_score[i] = est.loss_(y_test, y_pred)
AttributeError Traceback (most recent call last)
<ipython-input-188-bbd634856a9f> in <module>
9 test_score = np.zeros((Iterations,), dtype=np.float64)
10
---> 11 for i, y_pred in enumerate(est.staged_predict(X_test)):
12 test_score[i] = est.loss_(y_test, y_pred)
13
AttributeError: 'GridSearchCV' object has no attribute 'staged_predict'
任何人都可以就可能出现的问题提供一些见解。我很确定 staged_predict 仍然包含在 scikit learn 的 Model_Selection 模块中。
解决方案
推荐阅读
- r - 在现有行之间添加具有特定值的行
- python - 如何将条形码渲染格式化字符串转换为 html
- markdown - 如何使用 Markdown 创建一个只有一行的表
- javascript - 使用 Javascript 在表格单元格中查找值
- php - 如何在源代码中隐藏 POST 请求中使用的参数?
- asp.net-mvc - Asp.net 客户端数据库或数据表
- node.js - GCloud AppEngine nodejs 应用程序在第一次请求时返回 404,但后续请求成功
- amazon-web-services - 使用 Route 53 在单个域的路由上设置不同的应用程序
- python - 了解为什么我在尝试发布数据时收到 HTTP 400 错误代码
- macos - /Users/.../.zshrc:source:69: 没有这样的文件或目录:/Users/.../.oh-my-zsh/oh-my-zsh.sh