在lightgbm中定义自定义损失时出现细分错误

时间:2020-02-07 20:58:30

标签: machine-learning lightgbm boosting

在Lightgbm中,我一直在为回归任务尝试以下自定义损失,并提升type =“ goss”,但遇到了细分错误:

def hm(y_true, y_pred):
    residual = (y_true - y_pred).astype("float")
    residual_abs = np.fabs(residual)
    grad = np.where(residual_abs<=300, 
                    np.copysign(1, -residual)* 0.5,
                    np.where(residual_abs>=900, 
                             np.copysign(1, -residual)* 1,
                             np.copysign(1, -residual)* 2))
    hess = np.ones(y_true.shape[0]) 
    return grad, hess

任何想法为什么会失败?我正在使用高斯和默认超参数

0 个答案:

没有答案
相关问题