LightGBM icon indicating copy to clipboard operation
LightGBM copied to clipboard

`lightgbm.cv` set balanced sample_weights according to each training fold target

Open carlosg-m opened this issue 4 months ago • 0 comments

Summary

Just like https://github.com/microsoft/LightGBM/issues/5797, there should be a way to set sample weights for each fold. In the case of multiclass objective, the only way to balance classes is to set sample weights for the entire dataset.

The problem is that setting sample_weights on the whole dataset before K-Fold introduces leakage.

Another alternative is the Focal Loss cost function with gamma set to zero and alpha set to class weights. But there is no such cost function in LightGBM.

Motivation

Provide custom sample weights to each lightgbm.cv fold without introducing leakage, for class balancing or other purposes.

carlosg-m avatar Nov 29 '25 11:11 carlosg-m