如何解决在 Catboost 中创建自定义损失函数
我正在尝试创建一个自定义的损失函数以在 catboost 中使用。这是我试图实现的功能:
class ErrorLoss(object):
def calc_ders_range(self,approxes,targets,weights):
a = (approxes >= targets)
b = sum(a)
s = a.shape[0]
percentage = b / s
error=(targets - approxes)**2
cases=targets.shape[0]
loss=(percentage)+((np.sqrt(sum(error)/cases))/np.mean(targets))
return loss
这是我训练模型时得到的错误
catboostError:line 11,in calc_ders_range
a = (approxes >= targets)
TypeError: '>=' not supported between instances of '_catboost._DoubleArrayWrapper' and '_catboost._FloatArrayWrapper'
这是我要训练的模型
model = catboostRegressor(iterations=20,learning_rate=0.001,loss_function = ErrorLoss(),eval_metric = 'MAE')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。