我正在尝试创建一个定制的损耗函数,用于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')
目前没有回答
相关问题 更多 >
编程相关推荐