如何在XGBoost或其他估计器中编写定制包装器以用于预测功能
因此,我想操纵我的预测结果,需要在估算器中进行。我试图写这样的包装器,但是当我执行预测功能时,我的内核只是死了。从我的理解中,这应该替换XGBoost中的预测功能,对吗?
from xgboost import XGBRegressor as xgb
class custXGB(xgb):
def predict(self, X, y=None):
return self.predict(X)
然后,我正常适合CLA,但是当我使用时,预测内核死亡而不会出错:
estimator = custXGB()
estimator.fit(X_train, y_train)
# works fine
estimator.predict(X_train)
#kernel dies
So I want to manipulate the result of my prediction and I need to do it within the estimator. I tried to write a wrapper like this, but my kernel just dies when I execute the predict function. From my understanding this should just replace the predict function in xgboost right?
from xgboost import XGBRegressor as xgb
class custXGB(xgb):
def predict(self, X, y=None):
return self.predict(X)
I then fit the clas normally but when I use predict the kernel dies without error:
estimator = custXGB()
estimator.fit(X_train, y_train)
# works fine
estimator.predict(X_train)
#kernel dies
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经写了一个无限循环:您的
预测
是调用本身,而不是xgbRegressor.predict
。self
用super()
在方法内替换。You've written an infinite loop: your
predict
is calling itself, not theXGBRegressor.predict
. Replaceself
withsuper()
inside the method.