cthulhu
cthulhu

Reputation: 1

from fancyimpute import KNN: AttributeError: 'KNN' object has no attribute 'fit_transform'

Newbie in python and this is my first question.

System information: Windows 7, python 3.8.9,not using virtualenv yet.

I wanted to use impute techniques from fancyimpute module in my dataframe (null_dataframe_constant).

Trying to use fancyimpute module requires tensorflow along with numpy 1.20.0 version or newest. But tensorflow 2.4.1 (current latest version) requires numpy 1.19.2 or previous versions.

When using numpy 1.19.2 and importing fancyimpute it throws

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

When using numpy 1.20.2, fancyimpute seems to work, but running the script below throws error.


    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'

Any ideas?

I have installed these module versions:

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

Upvotes: 0

Views: 707

Answers (1)

cthulhu
cthulhu

Reputation: 1

After a lot of search i tried something for fun. I tried to use complete() instead of fit_transform() method. It worked fine,although i thought i was using new module version which requires fit.transform()

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

Upvotes: 0

Related Questions