Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第七章中关于xgboost的实现可能不准确 #5

Open
bufuchangfeng opened this issue Jan 16, 2021 · 1 comment
Open

第七章中关于xgboost的实现可能不准确 #5

bufuchangfeng opened this issue Jan 16, 2021 · 1 comment

Comments

@bufuchangfeng
Copy link

您好,在/code/chapter7.py中,第695行-699行

def _gain(self, y, y_pred):
# 计算信息
nominator = np.power((y * self.loss.grad(y, y_pred)).sum(), 2)
denominator = self.loss.hess(y, y_pred).sum()
return nominator / (denominator + self.lambd)

其中np.power((y*.......),这个乘以y是否是多余的呢?印象中似乎不需要这么做。

此外,我自己实现的xgboost和另外两个xgboost的开源实现都没有这个乘以y

以下是三个xgboost实现的链接。

https://github.com/bufuchangfeng/DecisionTree/blob/master/XGBoost.ipynb
https://github.com/RRdmlearning/Machine-Learning-From-Scratch/blob/master/xgboost/xgboost_model.py
https://github.com/RudreshVeerkhare/CustomXGBoost/blob/master/CustomXGBoost.py

感谢您提供了如此有帮助的代码。
期待您的回复。

@Zhangyuan0925
Copy link

谢谢你的纠错,抱歉没有及时回复你的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants