Skip to content

Commit 0447dd9

Browse files
DOC added example to permutation importance (scikit-learn#16460)
1 parent 9a4bd37 commit 0447dd9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sklearn/inspection/_permutation_importance.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ def permutation_importance(estimator, X, y, scoring=None, n_repeats=5,
100100
----------
101101
.. [BRE] L. Breiman, "Random Forests", Machine Learning, 45(1), 5-32,
102102
2001. https://doi.org/10.1023/A:1010933404324
103+
104+
Examples
105+
--------
106+
>>> from sklearn.linear_model import LogisticRegression
107+
>>> from sklearn.inspection import permutation_importance
108+
>>> X = [[1, 9, 9],[1, 9, 9],[1, 9, 9],
109+
... [0, 9, 9],[0, 9, 9],[0, 9, 9]]
110+
>>> y = [1, 1, 1, 0, 0, 0]
111+
>>> clf = LogisticRegression().fit(X, y)
112+
>>> result = permutation_importance(clf, X, y, n_repeats=10,
113+
... random_state=0)
114+
>>> result.importances_mean
115+
array([0.4666..., 0. , 0. ])
116+
>>> result.importances_std
117+
array([0.2211..., 0. , 0. ])
103118
"""
104119
if not hasattr(X, "iloc"):
105120
X = check_array(X, force_all_finite='allow-nan', dtype=None)

0 commit comments

Comments
 (0)