0

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

系统信息:Windows 7,python 3.8.9,尚未使用 virtualenv。

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

尝试使用 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
4

1 回答 1

0

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

from fancyimpute import KNN
knn_imputer = KNN()
null_dataframe_constant.iloc[:, :] = knn_imputer.complete(null_dataframe_constant)
于 2021-04-23T16:33:21.817 回答