【问题标题】:Catboost custom loss functionCatboost 自定义损失函数
【发布时间】:2020-11-16 02:56:55
【问题描述】:

我正在尝试实现我的自定义损失函数。在分析恶化的预测质量时,我提到自定义损失函数在交叉验证上的表现更差(至少不同),即使在文档中作为示例提供了 Logloss 实现。我希望它等于“本机”catboost Logloss。

这是我正在使用的示例: https://catboost.ai/docs/concepts/python-usages-examples.html#user-defined-loss-function

class LoglossObjective(object):
    def calc_ders_range(self, approxes, targets, weights):
        assert len(approxes) == len(targets)
        if weights is not None:
            assert len(weights) == len(approxes)        
        result = []
        for index in range(len(targets)):
            e = np.exp(approxes[index])
            p = e / (1 + e)
            der1 = targets[index] - p
            der2 = -p * (1 - p)
            if weights is not None:
                der1 *= weights[index]
                der2 *= weights[index]
            result.append((der1, der2))
        return result

谁能解释为什么用户定义的 logloss 与 catboost “native” logloss 不同?以及如何让用户定义的预测质量和“native”一样好?

【问题讨论】:

    标签: catboost


    【解决方案1】:

    找到答案:使用“native”logloss 运行时 CatboostClassifier 会自动调整 learning_rate,而在运行自定义 logloss 时使用默认 learning_rate。因此结果不同。

    明确设置 learning_rate 会导致相同的训练结果。

    【讨论】:

      猜你喜欢
      • 2020-12-19
      • 2017-04-04
      • 2017-12-18
      • 2020-03-27
      • 2019-05-27
      • 2020-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多