错误: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'

任何人都可以就可能出问题的地方提供一些见解。我很确定scikit Learn的Model_Selection模块中仍然包含staged_predict。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...