Why can LightGBM warn about negative categorical values when the source column contains only positive integers?
Classic MLLevel: IntermediateCategorical integer encoding
Why can LightGBM warn about negative categorical values when the source column contains only positive integers?
Hints
- State the task, inputs and prediction target.
- Compare with a simple baseline: assumptions, objective and independent validation.
Answer
Categorical values are represented within the int32 range. Very large positive IDs can overflow or become invalid during conversion, producing warnings about negative values or uninformative features. Map categories to compact, nonnegative integer codes and keep that mapping consistent between train and inference. Do not interpret the codes as ordinal magnitudes. Handle missing and unseen categories deliberately instead of relying on unchecked integer casts.
Source and licence: LightGBM developers — Official FAQ · MIT · answer: Quantoros editorial