DOC added example to permutation importance
@@ -100,6 +100,21 @@ def permutation_importance(estimator, X, y, scoring=None, n_repeats=5,
----------
.. [BRE] L. Breiman, "Random Forests", Machine Learning, 45(1), 5-32,
2001. https://doi.org/10.1023/A:1010933404324
+
+ Examples
+ --------
+ >>> from sklearn.linear_model import LogisticRegression
+ >>> from sklearn.inspection import permutation_importance
+ >>> X = [[1, 9, 9],[1, 9, 9],[1, 9, 9],
+ ... [0, 9, 9],[0, 9, 9],[0, 9, 9]]
+ >>> y = [1, 1, 1, 0, 0, 0]
+ >>> clf = LogisticRegression().fit(X, y)
+ >>> result = permutation_importance(clf, X, y, n_repeats=10,
+ ... random_state=0)
+ >>> result.importances_mean
+ array([0.4666..., 0. , 0. ])
+ >>> result.importances_std
+ array([0.2211..., 0. , 0. ])
"""
if not hasattr(X, "iloc"):
X = check_array(X, force_all_finite='allow-nan', dtype=None)
