2
$\begingroup$

I am trying to implement a custom loss function in LightGBM for a regression problem. The intrinsic metrics do not help me much, because they penalise for outliers... Is there any way to use r2_score from sklearn as a loss function for LightGBM?

$\endgroup$

1 Answer 1

2
$\begingroup$

$R^2$ is just a rescaling of mean squared error, the default loss function for LightGBM; so just run as usual. (You could use another builtin loss (MAE or Huber loss?) instead in order to penalize outliers less.)

$\endgroup$
1
  • $\begingroup$ Thanks so much!! I completely forgot about the fact that it is similar to MSE! $\endgroup$ Commented Apr 3, 2020 at 22:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.