Issue
Trying to import Imputer from sklearn.preprocessing,
import pandas as pd
dataset = pd.read_csv('Data.csv')
X = dataset.iloc[:, :-1].values
y = dataset.iloc[:, 3].values
#PART WHERE ERROR OCCURS:-
from sklearn.preprocessing import Imputer
Shows "ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing' (/home/codeknight13/anaconda3/lib/python3.7/site-packages/sklearn/preprocessing/_init_.py)"
Solution
from sklearn.preprocessing import Imputer
was deprecated with scikit-learn v0.20.4
and removed as of v0.22.2
. See the sklean changelog.
from sklearn.impute import SimpleImputer
import numpy as np
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')
pip install scikit-learn==0.20.4
or conda install scikit-learn=0.20.4
are not a good options because it's more than 3 years out of date.
Answered By - deramko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.