Skip to content

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

Description

@bufuchangfeng

您好,在/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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions