model_diagnostics/unseeded-stochastic-diagnostics
| Pack | Severity | Fix | Versions |
|---|---|---|---|
| model-diagnostics | warning | unsafe, with xpd check --fix --unsafe-fixes |
All versions |
compute_permutation_importance, plot_permutation_importance, compute_partial_dependence, compute_marginal, and plot_marginal subsample rows (via n_max) or permute feature columns randomly using rng=None by default, causing diagnostic tables and plots to drift between runs.
compute_permutation_importance(model.predict, X_val, y_val)compute_permutation_importance(model.predict, X_val, y_val, rng=0)compute_marginal(y_val, y_pred, X_val, feature_name="x0", n_max=500, rng=None)compute_marginal(y_val, y_pred, X_val, feature_name="x0", n_max=500, rng=0)What the rule reports
Section titled “What the rule reports”Calls to compute_permutation_importance, plot_permutation_importance, compute_partial_dependence, compute_marginal, or plot_marginal outside tests where rng= is omitted or explicitly None.
How to fix it
Section titled “How to fix it”Pass a fixed integer seed (rng=0) or a seeded numpy.random.default_rng(0) instance.
Diagnostic message
Section titled “Diagnostic message”$C without a fixed rng= draws unseeded random permutations or subsamples and changes results across runs. Pass rng=0 (or a seeded numpy.random.Generator).See all rules in the model-diagnostics pack.