rules/lightgbm/sample-weight-without-eval-weight.md

Passing sample_weight to LightGBM estimator fit() weights training gradients and Hessians, while validation sets (eval_X and eval_y, or eval_set) are scored unweighted unless eval_sample_weight is also passed. Early stopping and validation curves then optimize a different loss than training.

diff
1-model.fit(
2- X_train,
3- y_train,
4- sample_weight=w_train,
5- eval_X=(X_val,),
6- eval_y=(y_val,),
7-)
8+model.fit(
9+ X_train,
10+ y_train,
11+ sample_weight=w_train,
12+ eval_X=(X_val,),
13+ eval_y=(y_val,),
14+ eval_sample_weight=[w_val],
15+)

What the rule reports

Calls to fit() on a LightGBM scikit-learn estimator (LGBMRegressor, LGBMClassifier, LGBMRanker, or LGBMModel) that pass a non-None sample_weight together with a validation set (eval_X, eval_y, or eval_set) without a non-None eval_sample_weight.

How to fix it

Pass eval_sample_weight=[w_val] (one weight array per validation set in the same order) so validation loss and early stopping match the weighted objective.