项目场景:
在使用XGBoost训练时,遇到如下报错:
Parameters: { "silent" } might not be used.
This may not be accurate due to some parameters are only used in language bindings but passed down to XGBoost core.
Or some parameters are not used but slip through this verification.
Please open an issue if you find above cases.
问题描述:
代码行
paramenters=list(itertools.product(range(30,120,1),[4]))
for i in paramenters:
n_round = i[0]
param_xgb={'max_depth':i[1],'silent':False,'eta':0.1,'n_jobs':-1,'booster':'gbtree','seed':1}
xgbr=xgb.train(param_xgb,dtrain,n_round)
r2test=r2_score(ytest,xgbr.predict(dtest))
if r2test>0.84:
print(i)
print('training R2 = ' + str(round(r2_score(ytrain,xgbr.predict(dtrain)), 3)))
print('training RMSE = %.3f' % np.sqrt(mean_squared_error(y_true=ytrain, y_pred=xgbr.predict(dtrain))))
print('test R2 = ' + str(round(r2_score(ytest,xgbr.predict(dtest)), 3)))
print('test RMSE = %.3f' % np.sqrt(mean_squared_error(y_true=ytest, y_pred=xgbr.predict(dtest))))
解决方案:
提示:这里填写问题的分析:
这是因为最新的xgboost已经移除了silent参数,最新版本的小伙伴会遇到这种问题,应该把silent换成
{'verbosity':0}