rules/model_diagnostics/weights-keyword-argument.md
model_diagnostics uses weights= instead of scikit-learn's sample_weight= and rng= instead of random_state=. Passing sample_weight= or random_state= raises TypeError: got an unexpected keyword argument.
diff
| 1 | -decompose(y_val, y_pred, sample_weight=w_val, scoring_function=SquaredError()) |
| 2 | +decompose(y_val, y_pred, weights=w_val, scoring_function=SquaredError()) |
| 3 | -compute_permutation_importance(model.predict, X_val, y_val, sample_weight=w_val, random_state=0) |
| 4 | +compute_permutation_importance(model.predict, X_val, y_val, weights=w_val, rng=0) |
What the rule reports
Calls to model_diagnostics scoring, calibration, or XAI functions passing sample_weight= instead of weights=, or random_state= instead of rng=.
How to fix it
Rename sample_weight= to weights= and random_state= to rng= (or run xpd check --fix --unsafe-fixes).