python-3.x - pandas_ml 坏了吗?

标签 python-3.x scikit-learn pandas-ml

版本信息和问题如下。我想知道 pandas_ml 是坏了还是我做错了什么。为什么我无法导入 pandas_ml?

基础信息:
sklearn 和 pandas_ml 和 python 的版本如下:

Python                            3.8.2
scikit-learn                      0.23.0
pandas-ml                         0.6.1

问题:
import pandas_ml as pdml

返回以下错误:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-47-79d5f9d2381c> in <module>
----> 1 import pandas_ml as pdml
      2 #from pandas_ml import ModelFrame
      3 #mf = pdml.ModelFrame(df.to_dict())
      4 #mf.head()

d:\program files\python38\lib\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

d:\program files\python38\lib\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

d:\program files\python38\lib\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

d:\program files\python38\lib\site-packages\pandas_ml\skaccessors\__init__.py in <module>
     13 from pandas_ml.skaccessors.linear_model import LinearModelMethods                 # noqa
     14 from pandas_ml.skaccessors.manifold import ManifoldMethods                        # noqa
---> 15 from pandas_ml.skaccessors.metrics import MetricsMethods                          # noqa
     16 from pandas_ml.skaccessors.model_selection import ModelSelectionMethods           # noqa
     17 from pandas_ml.skaccessors.neighbors import NeighborsMethods                      # noqa

d:\program files\python38\lib\site-packages\pandas_ml\skaccessors\metrics.py in <module>
    254 _true_pred_methods = (_classification_methods + _regression_methods
    255                       + _cluster_methods)
--> 256 _attach_methods(MetricsMethods, _wrap_target_pred_func, _true_pred_methods)
    257 
    258 

d:\program files\python38\lib\site-packages\pandas_ml\core\accessor.py in _attach_methods(cls, wrap_func, methods)
     91 
     92         for method in methods:
---> 93             _f = getattr(module, method)
     94             if hasattr(cls, method):
     95                 raise ValueError("{0} already has '{1}' method".format(cls, method))

AttributeError: module 'sklearn.metrics' has no attribute 'jaccard_similarity_score'

最佳答案

看来确实如此。这是情况:

虽然函数jaccard_similarity_score未显示在 sklearn.metrics 的可用版本中在 documentation ,除了 source code 之外,它仍然在引擎盖下(因此可用)直到 v0.22.2( jaccard_score )一。但是在latest v0.23的源代码中,已被删除,只有 jaccard_score遗迹。

这意味着仍然可以通过简单地将 scikit-learn 降级到 v.0.22.2 来使用 pandas-ml。但不幸的是,这也不起作用,抛出一个不同的错误:

!pip install pandas-ml
# Successfully installed enum34-1.1.10 pandas-ml-0.6.1

import sklearn
sklearn.__version__
# '0.22.2.post1'

import pandas_ml as pdml

[...]

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

我想可以通过回溯足够多的时间来找到一个适用于它的 scikit-learn 版本(他们 Github repo 中的最后一次提交是在 2019 年 3 月),但不确定是否值得大惊小怪。无论如何,他们甚至没有在他们的 requirements file 中提到 scikit-learn(更不用说它的任何特定版本)。 ,这似乎不是很好的做法,整个项目似乎都被放弃了。

关于python-3.x - pandas_ml 坏了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61819628/

相关文章:

python - GridsearchCV 异常

python - 属性错误: module 'pandas.compat' has no attribute 'iteritems'

Python 请求奇怪的 URL %-编码

python - 使用 Python v3.x 和 C API 解释 Python v2.5 代码(关于整数除法)

python-3.x - 如何修复 'C extension not loaded, training will be slow. Install a C compiler and reinstall gensim for fast training.'

python-3.x - 有没有办法减少 Spacy 安装的大小?

python - 类型错误 : unsupported operand type(s) for -: 'int' and 'StandardScaler

python - 如何覆盖 Sklearn 的 TSNE 以在 Pipeline 函数中使用?