无法从pandas_ml的“sklearn.preprocessing”导入名称“inputer”

2024-05-19 23:00:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为我的主人做一个项目,我试图得到一些关于我计算的数据。我发现了一个非常酷的工具来实现这一点,名为panda_ml,但当我在jupyter上的单元格中导入它时,如下所示:

from pandas_ml import *

它给我这个输出错误:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-118-93009f7254d4> in <module>
      3 from sklearn import *
      4 from matplotlib.colors import LogNorm
----> 5 from pandas_ml import *
      6 import math
      7 

~/anaconda3/envs/Lab1_B/lib/python3.7/site-packages/pandas_ml/__init__.py in <module>
      1 #!/usr/bin/env python
      2 
----> 3 from pandas_ml.core import ModelFrame, ModelSeries       # noqa
      4 from pandas_ml.tools import info                         # noqa
      5 from pandas_ml.version import version as __version__     # noqa

~/anaconda3/envs/Lab1_B/lib/python3.7/site-packages/pandas_ml/core/__init__.py in <module>
      1 #!/usr/bin/env python
      2 
----> 3 from pandas_ml.core.frame import ModelFrame       # noqa
      4 from pandas_ml.core.series import ModelSeries     # noqa

~/anaconda3/envs/Lab1_B/lib/python3.7/site-packages/pandas_ml/core/frame.py in <module>
      8 
      9 import pandas_ml.imbaccessors as imbaccessors
---> 10 import pandas_ml.skaccessors as skaccessors
     11 import pandas_ml.smaccessors as smaccessors
     12 import pandas_ml.snsaccessors as snsaccessors

~/anaconda3/envs/Lab1_B/lib/python3.7/site-packages/pandas_ml/skaccessors/__init__.py in <module>
     17 from pandas_ml.skaccessors.neighbors import NeighborsMethods                      # noqa
     18 from pandas_ml.skaccessors.pipeline import PipelineMethods                        # noqa
---> 19 from pandas_ml.skaccessors.preprocessing import PreprocessingMethods              # noqa
     20 from pandas_ml.skaccessors.svm import SVMMethods                                  # noqa

~/anaconda3/envs/Lab1_B/lib/python3.7/site-packages/pandas_ml/skaccessors/preprocessing.py in <module>
     11     _keep_col_classes = [pp.Binarizer,
     12                          pp.FunctionTransformer,
---> 13                          pp.Imputer,
     14                          pp.KernelCenterer,
     15                          pp.LabelEncoder,

AttributeError: module 'sklearn.preprocessing' has no attribute 'Imputer'

我使用的是Conda,我有我自己的env和所有的软件包,我尝试过安装旧版本的sklearn和pandas_ml,但没有解决问题。我四处寻找,但似乎没有人有过这个问题……你有什么建议吗


Tags: infrompyimportpandaslibpackagessite
3条回答

我最近安装了scikit-learn版本0.22.1,并且遇到了类似的问题。然后我在Python 3.7.2下尝试了您的解决方案,维护了Pandas{}和Pandas ML{}的版本,它工作起来很有魅力!。我想知道什么时候可以安全地使用更新版本的scikit-learn

您必须正确卸载,降级将起作用

pip uninstall -y scikit-learn
pip uninstall -y pandas
pip uninstall -y pandas_ml

pip install scikit-learn==0.21.1
pip install pandas==0.24.2
pip install pandas_ml

然后导入

from pandas_ml import *

Python 3.8.2中测试

from sklearn.impute import SimpleImputer
imp = SimpleImputer(missing_values=np.nan, copy=False, strategy="mean", )

不再需要轴值

相关问题 更多 >