PermutationImportance
Permutation importance — feature importance by permuting each column and measuring score drop. / Importance par permutation — importance des features en permutant chaque colonne et mesurant la baisse de score.
⚡ Rust-native
✓ sklearn parity
Quick start — Python
import seraplot as sp, json, numpy as np
X = np.random.randn(200, 5)
y = X @ [2, -1, 0, 0.5, 1.2] + np.random.randn(200) * 0.3
model = sp.Ridge(alpha=0.5)
model.fit(X, y)
imp = sp.permutation_importance(model, X, y, n_repeats=5)
print(imp.importances_mean_)
EN — Drop-in replacement:
FR — Remplacement direct : même API que sklearn, changez l'import.
sp.PermutationImportance has the same API as sklearn.FR — Remplacement direct : même API que sklearn, changez l'import.
API Reference
JSON function name
ml_permutation_importance — aliases: permutation_importance
Python class
sp.PermutationImportance(n_repeats=10, scoring=auto)
Constructor Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
n_repeats | int | 10 | Number of permutations per feature. |
scoring | str | auto | Scoring metric: auto-detects cls/reg. |
Returns
JSON with importances_mean, importances_std per feature.
Algorithm
$$\text{imp}j = \bar{s} - \frac{1}{K}\sum{k=1}^{K} s(\text{perm}_k(X_j))$$
Example
import seraplot as sp, json, numpy as np
X = np.random.randn(200, 5)
y = X @ [2, -1, 0, 0.5, 1.2] + np.random.randn(200) * 0.3
model = sp.Ridge(alpha=0.5)
model.fit(X, y)
imp = sp.permutation_importance(model, X, y, n_repeats=5)
print(imp.importances_mean_)
Référence API
Nom de fonction JSON
ml_permutation_importance — alias : permutation_importance
Classe Python
sp.PermutationImportance(n_repeats=10, scoring=auto)
Paramètres du constructeur
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
n_repeats | int | 10 | Nombre de permutations par feature. |
scoring | str | auto | Métrique de scoring : auto-détecte cls/reg. |
Retourne
JSON avec importances_mean, importances_std par feature.
Algorithme
$$\text{imp}j = \bar{s} - \frac{1}{K}\sum{k=1}^{K} s(\text{perm}_k(X_j))$$
Exemple
import seraplot as sp, numpy as np
X = np.random.randn(200, 5)
y = X @ [2, -1, 0, 0.5, 1.2] + np.random.randn(200) * 0.3
model = sp.Ridge(alpha=0.5)
model.fit(X, y)
imp = sp.permutation_importance(model, X, y, n_repeats=5)
print(imp.importances_mean_)