簡體   English   中英

ModuleNotFoundError:沒有名為“sklearn.inspection”的模塊

[英]ModuleNotFoundError: No module named 'sklearn.inspection'

我正在關注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

我嘗試從sklearn.inspection導入permutation_importance ,但我得到了

Traceback (most recent call last):
  File "train.py", line 20, in <module>
    from sklearn.inspection import permutation_importance
ModuleNotFoundError: No module named 'sklearn.inspection'

我的 sklearn 版本是0.20.3

import sklearn
print(sklearn.__version__)

# result: 0.20.3

sklearn.inspection版本 0.21.0中引入的新子包。

我需要執行pip install --upgrade scikit-learn升級到最新版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM