Reputation: 30022
I'm following the example in sklearn.inspection.permutation_importance.
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
result.importances_std
I try to import permutation_importance
from sklearn.inspection
, but I get
Traceback (most recent call last):
File "train.py", line 20, in <module>
from sklearn.inspection import permutation_importance
ModuleNotFoundError: No module named 'sklearn.inspection'
My sklearn version is 0.20.3
import sklearn
print(sklearn.__version__)
# result: 0.20.3
Upvotes: 1
Views: 7061
Reputation: 30022
sklearn.inspection is a new subpackage introduced in Version 0.21.0.
I need to execute pip install --upgrade scikit-learn
to upgrade the sklearn to the newest version.
Upvotes: 1