lightgbm.basic.LightGBMError: Cannot set categorical feature after freed raw data, set free_raw_data

时间:2024-05-23 19:36:59

lightgbm.basic.LightGBMError: Cannot set categorical feature after freed raw data, set free_raw_datalightgbm.basic.LightGBMError: Cannot set categorical feature after freed raw data, set free_raw_data=False when construct Dataset to avoid this.

已经在机器学习行业用lgb算法好久了,还是第一次遇到这个错误

原因:使用lgb训练完模型后,lgb_train, lgb_eval变量虽然还存在,但是在实际内存中已经释放掉原始数据了,所以没法再继续训练模型

解决办法:再重新生成一次这两个变量即可