Search code examples
pythonlightgbm

LightGBM warning: "Met abs(label) < 1"


I'm doing Regression with MAPE (Mean Absolute Percentage Error) objective and eva_metric.

What is the meaning of the following warning?

[LightGBM] [Warning] Met 'abs(label) < 1', will convert them to '1' in MAPE objective and metric

Solution

  • This question was cross-posted to the LightGBM issues page. Copying over my answer from there (hhttps://github.com/microsoft/LightGBM/issues/3608#issuecomment-735930682).

    There are values in your target variable which have an absolute value < 1. MAPE is unstable under such conditions, so LightGBM converts those values to 1.0 before evaluation. This warning is telling you that that's happening.

    The code where this rounding happens: https://github.com/microsoft/LightGBM/blob/3e8e24b374fbfe6522e39862a79c81b2bea8b259/src/metric/regression_metric.hpp#L248-L250

    To see this instability, consider the following MAPE on a single prediction.

    enter image description here

    Rounding to 1 like this also avoids the case where calculating MAPE fails with a divide-by-zero error because the target is exactly 0.

    If you want to use MAPE as an evaluation metric and are uncomfortable with the way that LightGBM is using rounding to calculate it in this setting, I recommend altering your target variable to ensure that all the values are > 1 in absolute value.