【发布时间】: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