当前位置:网站首页>Successfully solved: importerror: cannot import name 'import' from 'sklearn preprocessing

Successfully solved: importerror: cannot import name 'import' from 'sklearn preprocessing

2022-06-10 06:45:00 Xiao Yuan itsuper

Successfully solved :ImportError: cannot import name ‘Imputer‘ from ‘sklearn.preprocessing

Preface

This article has been included in :《 a farewell Bug》 special column

This column is used to record all kinds of difficulties encountered in study and work Bug Problems and Solutions + resolvent , Including program installation 、 Problems in running the program, etc , If you encounter other problems after subscribing to the column, you can chat privately to help solve them !!!

Report the wrong question

My code

from sklearn.preprocessing import Imputer

Error message

ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing' (D:\Python3.8\lib\site-packages\sklearn\preprocessing\__init__.py)

 Insert picture description here

Error reason

Error report translation

ImportError: from “sklearn” Import name “inputer”. Preprocessing '(D:\Python3.8\lib\site packages\sklearn\preprocessing\uu init\uuuuuuu.py) 

Error reason :0.20 New features :SimpleImputer Instead of the old sklearn.preprocessing.Imputer

resolvent

1、 Replace the import library statement with the following statement

from sklearn.impute import SimpleImputer

2、 The original used in the program Imputer Change it to SimpleImputer that will do

 Insert picture description here

3、 Run again successfully

[[ 1.28620952e-15  3.82970843e+00]
 [ 5.74456265e+00 -1.91485422e+00]
 [-5.74456265e+00 -1.91485422e+00]]
原网站

版权声明
本文为[Xiao Yuan itsuper]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/161/202206100639388753.html