150 samples are generated from a known linear process, then a small linear-regression model ŷ = w₀ + w₁f₁ + w₂f₂ + w₃f₃ is fit to them by ordinary least squares (closed-form normal equations, solved with Gaussian elimination — this is the exact "black box" being explained).
Permutation importance for feature j:
MSE_base = mean( (ŷ(X) − y)² )
MSE_perm_j = mean( (ŷ(X_perm_j) − y)² ) [column j shuffled, others untouched]
Importance_j = mean over K shuffles of (MSE_perm_j − MSE_base)
Shuffling a feature that the model actually relies on destroys the correlation it needs and prediction error jumps — a large Δ. Shuffling a feature the model barely uses changes almost nothing — Δ stays near zero. This is model-agnostic: it never looks inside the model, only at how its error responds to breaking one input's relationship to the rest.
The scatter plot's x-axis follows whichever feature (f1/f2/f3) is currently selected for permutation, and the y-axis is always the true target value — so shuffling the selected feature visibly scrambles the x-vs-y relationship the model depends on, while the point colors (green→red) track each sample's live prediction error.
- f1 / f2 / f3 buttons — choose which feature column gets shuffled and shown on the x-axis.
- Shuffle repeats — permutation importance is noisy for a single shuffle, so K independent shuffles are run and averaged, as scikit-learn's
permutation_importance does.
- Run Permutation Test — performs the shuffle-and-reevaluate cycle; every point recolors from green (low error) to red (high error) using the model's prediction under the permuted feature.
- Drag to pan, scroll to zoom the scatter plot; Reset View restores the default framing.
- The true data-generating weights are 3.0, −2.0 and 0.15 for f1, f2, f3 — so a correct permutation test should rank f1 > f2 ≫ f3, even though the fitted model never sees those numbers directly.
Real-world relevance: this is the workhorse interpretability technique used whenever SHAP is too slow to run on a large tabular model — it works on any fitted predictor without retraining, and is the default "which feature matters" answer in most production ML monitoring dashboards.