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?
1 Answer
$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.)
-
$\begingroup$ Thanks so much!! I completely forgot about the fact that it is similar to MSE! $\endgroup$ Apr 3, 2020 at 22:02