[SOLVED] Cannot import Imputer

Some of you might be getting the following error while working on the End-to-End project in Machine Learning:

Cannot import name Imputer

You would be getting this error on the following code:

from sklearn.preprocessing import Imputer

Please note that the class has been deprecated, you would not be able to use it anymore. Please use the following code instead:

from sklearn.impute import SimpleImputer
imputer = SimpleImputer(strategy=‘median’)

1 Like

Hi, Raj
this is the error:
File “”, line 2
imputer = SimpleImputer(strategy=‘median’)
^
SyntaxError: invalid character in identifier

Hi,

Would request you to share a screenshot of your code and the error that you are getting.

Thanks.

Hi, Rajtilak,
FYI
Error:
File “”, line 4
imputer = Imputer(strategy=“median”)from sklearn.impute import SimpleImputer
^
SyntaxError: invalid syntax

if you can call me once.
Regards
Mrityunjay Das
9540329668

Hi Mrityunjay,

Try this code exactly:

Capture

Regards