lightgbm报错:AttributeError: 'LGBMRegressor' object has no attribute 'best_iteration'

在进行预测的时候,y_pred_1 = gbm.predict(X_val, num_iteration=gbm.best_iteration)

lightgbm报上述错误。

查阅官方文档后,明白与参数early_stopping_rounds

  • early_stopping_rounds (int or None, optional (default=None)) – Activates early stopping. The model will train until the validation score stops improving. Requires at least one validation data and one metric. If there’s more than one, will check all of them. If early stopping occurs, the model will add best_iteration field.

early_stopping_rounds(int或None,可选(default = None)) - 激活提前停止。 该模型将训练,直到验证分数停止改进。 至少需要一个验证数据和一个指标。 如果有多个,将检查所有这些。 如果提前停止,模型将添加best_iteration字段。

 

最后一句的意思是如果模型提前停止,模型才会添加best_iteration。如果没有提前停止,就不会有这个参数。不知道我的理解对不对。。。

要是不对,欢迎指正!

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值