【问题标题】:from fancyimpute import KNN: AttributeError: 'KNN' object has no attribute 'fit_transform'from fancyimpute import KNN: AttributeError: 'KNN' object has no attribute 'fit_transform'
【发布时间】:2021-07-12 17:47:33
【问题描述】:

python 新手,这是我的第一个问题。

系统信息: Windows 7,python 3.8.9,还没有使用 virtualenv。

我想在我的数据框 (null_dataframe_constant) 中使用来自 fancyimpute 模块的插补技术。

尝试使用 fancyimpute 模块需要 tensorflow 以及 numpy 1.20.0 版本或最新版本。 但是 tensorflow 2.4.1(当前最新版本)需要 numpy 1.19.2 或之前的版本。

当使用 numpy 1.19.2 并导入 fancyimpute 时会抛出

:ImportError: numpy.core.multiarray failed to import"

使用 numpy 1.20.2 时,fancyimpute 似乎可以工作,但运行下面的脚本会引发错误。


    from fancyimpute import KNN
    knn_imputer = KNN()
    null_dataframe_constant.iloc[:, :] = knn_imputer.fit_transform(null_dataframe_constant)

AttributeError: 'KNN' object has no attribute 'fit_transform'

有什么想法吗?

我已经安装了这些模块版本:

pylint==2.6.0
pyparsing==2.4.7
pyrsistent==0.16.0
python-dateutil==2.8.1
python-pptx==0.6.18
pytz==2020.1
pywin32==227
pywinpty==0.5.7
PyYAML==5.4.1
pyzmq==19.0.1
qtconsole==4.7.4
QtPy==1.9.0
requests==2.23.0
requests-oauthlib==1.3.0
retrying==1.3.3
rsa==4.7.2
scikit-learn==0.24.1
scipy==1.6.2
scs==2.1.3
seaborn==0.11.0
Send2Trash==1.5.0
six==1.15.0
sklearn==0.0
sortedcontainers==2.1.0
soupsieve==2.0.1
SpeechRecognition==3.8.1
spotipy==2.12.0
squarify==0.4.3
statsmodels==0.12.1
tensorboard==2.4.1
tensorboard-plugin-wit==1.8.0
tensorflow==2.4.1
tensorflow-estimator==2.4.0
termcolor==1.1.0
terminado==0.8.3
testpath==0.4.4
textract==1.6.3
Theano==1.0.5
threadpoolctl==2.1.0
toml==0.10.2
tornado==6.0.4
traitlets==4.3.3
typing-extensions==3.7.4.3
tzlocal==1.5.1
urllib3==1.25.9
wcwidth==0.1.9
webencodings==0.5.1
Werkzeug==1.0.1
widgetsnbextension==3.5.1
wrapt==1.12.1
xlrd==1.2.0
XlsxWriter==1.2.8

【问题讨论】:

    标签: numpy tensorflow python-3.8 fancyimpute


    【解决方案1】:

    经过大量搜索后,我尝试了一些有趣的东西。 我尝试使用 complete() 而不是 fit_transform() 方法。 它工作得很好,虽然我认为我正在使用需要 fit.transform() 的新模块版本

    from fancyimpute import KNN
    knn_imputer = KNN()
    null_dataframe_constant.iloc[:, :] = knn_imputer.complete(null_dataframe_constant)
    

    【讨论】:

      猜你喜欢
      • 2020-07-25
      • 2019-06-25
      • 2017-03-08
      • 2022-12-01
      • 2020-04-26
      • 2020-11-21
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      相关资源
      最近更新 更多