MingchaoZhu / DeepLearning

Python for《Deep Learning》,该书为《深度学习》(花书) 数学推导、原理剖析与源码级别代码实现
MIT License
6.39k stars 1.33k forks source link

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

Open bufuchangfeng opened 3 years ago

bufuchangfeng commented 3 years ago

您好,在/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 commented 2 years ago

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