【问题标题】:ImportError: cannot import name 'SimpleImputer'ImportError:无法导入名称“SimpleImputer”
【发布时间】:2020-04-07 03:41:39
【问题描述】:

我试试:

from sklearn.preprocessing import SimpleImputer
imp = SimpleImputer()
imputed = pd.DataFrame()   
imp.fit_transform(Final_df201911)

但我收到错误:ImportError: cannot import name 'SimpleImputer'

所以我做到了:

conda update anaconda

它完成了所有的下载,然后说,(在 anaconda 终端中):

Executing transaction: failed
ERROR conda.core.link:_execute(481): An error occurred while uninstalling package 'defaults::conda-4.4.10-py36_0'.
PermissionError(13, 'Access is denied')
Attempting to roll back.

Rolling back transaction: done

PermissionError(13, 'Access is denied')

我需要做什么才能获得 SimpleImputer?我正在使用 scikit-learn 版本 0.19.1

【问题讨论】:

  • 试试from sklearn.impute import SimpleImputer
  • @warped 它说:ModuleNotFoundError: No module named 'sklearn.impute' 我猜我在 anaconda 中的 sklearn 模块已经过时了。但是我得到了这个 PermissionError。那是怎么回事?
  • 如果你这样做from sklearn import *会发生什么?只想检查是否安装了sklearn。
  • @warped 还是一样的错误:/
  • 安装了什么版本的 scikit-learn?即,检查conda list scikit-learn 并将该输出添加到您的问题中。

标签: python scikit-learn anaconda


【解决方案1】:

我正在使用 scikit-learn 版本 0.19.1

在这个版本中只有Imputer (https://sklearn.org/modules/generated/sklearn.preprocessing.Imputer.html`)


SimpleImputer 出现在 0.22.


尝试安装最新版本:

 pip install -U scikit-learn

然后使用:

from sklearn.impute import SimpleImputer

来源:https://github.com/mindsdb/lightwood/issues/75

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-31
    • 2014-10-10
    • 2014-09-20
    • 2014-08-28
    • 2014-06-10
    • 2016-05-16
    • 2019-05-25
    • 2017-04-22
    相关资源
    最近更新 更多