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

Passing sample_weight to XGBoost estimator fit() weights training gradients and Hessians, while eval_set entries are scored unweighted unless sample_weight_eval_set 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_set=[(X_val, y_val)],
6-)
7+model.fit(
8+ X_train,
9+ y_train,
10+ sample_weight=w_train,
11+ eval_set=[(X_val, y_val)],
12+ sample_weight_eval_set=[w_val],
13+)

What the rule reports

Calls to fit() on an XGBoost scikit-learn estimator (XGBRegressor, XGBClassifier, XGBRanker, XGBRFRegressor, XGBRFClassifier, or XGBModel) that pass a non-None sample_weight together with a non-None eval_set without a non-None sample_weight_eval_set.

How to fix it

Pass sample_weight_eval_set=[w_val] (one weight array per eval_set tuple in the same order) so validation metrics and early stopping match the weighted training objective.