首页 > 解决方案 > AttributeError:“XGBClassifier”对象没有属性“_le”

问题描述

我正在尝试在 OOT 数据上拟合我的 xgboost 模型对象(0.60 版本),但不断出错。我正在使用下面的代码行:

fname = "xgb"  
if isinstance(xgb, XGBClassifier):
 regressor = XGBClassifier()
 r = pickle.load(open(fname, "rb" ))
 print(r)
 regressor._Booster = r._Booster
 regressor.set_params(**r.get_xgb_params())

y_predict = regressor.predict(oot)

错误:

AttributeError: 'XGBClassifier' object has no attribute '_le'

我还尝试使用其他方式对 OOT 数据进行评分:

scored = scored_data.predict(oot)

然后我得到以下错误(我创建了类似的环境复制模型开发)

class_probs = self.booster().predict(test_dmatrix,output_margin=output_margin,ntree_limit=ntree_limit)

TypeError: 'str' object is not callable

标签: pythonxgboostpredict

解决方案


推荐阅读