问题描述
我正在尝试创建一个自定义的损失函数以在 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 (将#修改为@)