tree.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:MLAlgorithms 作者: rushter 项目源码 文件源码
def _calculate_leaf_value(self, targets):
        """Find optimal value for leaf."""
        if self.loss is not None:
            # Gradient boosting
            self.outcome = self.loss.approximate(targets['actual'], targets['y_pred'])
        else:
            # Random Forest
            if self.regression:
                # Mean value for regression task
                self.outcome = np.mean(targets['y'])
            else:
                # Probability for classification task
                self.outcome = stats.itemfreq(targets['y'])[:, 1] / float(targets['y'].shape[0])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号