Closed ZoranPandovski closed 4 years ago
This is related with pip installing latest verzion of scikit-learn which was pre-release 0.22rc3 version. We should use fixed version that works 0.21.3. I will create PR
A new scikit-learn version 0.22 was released yesterday, but there are other errors with using that version. We should keep on 0.21.3 for now.
Fixed by #74
from sklearn.impute import SimpleImputer will work because of the following
DeprecationWarning: Class Imputer is deprecated; Imputer was deprecated in version 0.20 and will be removed in 0.22. Import impute.SimpleImputer from sklearn instead.
Thank you @AnasK95 It worked.
So I had to use,
from sklearn.impute import SimpleImputer
imputer = SimpleImputer(missing_values=np.nan, strategy='mean')
instead of
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values='NaN', strategy='mean', axis=0)
Otherwise, it gives the following error.
from sklearn.preprocessing import Imputer
ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing'
Thanks @AnasK95 and @subhashi It worked for me as well.
thanks it works
but 'axis' is no more a argument there ! btw tahnks @AnasK95 it worked!
Thank you @AnasK95.
Thank you @AnasK95 It worked. but how do we use axis argument functionality now?
Thanks a lot.
Sincerely thanks! @AnasK95
Thanks @subhashi
i try to upgrade it but !!!
hey, In version 0.22.2, for error: ImportError: cannot import name 'Imputer' from 'sklearn.preprocessing' (C:\Users\Anaconda3\lib\site-packages\sklearn\preprocessing__init__.py)
You can use this snippet, and it will work fine: (C:\Users\Anaconda3\lib\site-packages\sklearn\preprocessing__init__.py)
from .imputation import Imputer
all = [ . . .
'Imputer', # type 'imputer'
. . . ] <-------------------------------------------------------------> Hope this would help <------------------------------------------------------------> full init.py code here:
"""
The :mod:sklearn.preprocessing
module includes scaling, centering,
normalization, binarization and imputation methods.
"""
from ._function_transformer import FunctionTransformer
from .data import Binarizer from .data import KernelCenterer from .data import MinMaxScaler from .data import MaxAbsScaler from .data import Normalizer from .data import RobustScaler from .data import StandardScaler from .data import QuantileTransformer from .data import add_dummy_feature from .data import binarize from .data import normalize from .data import scale from .data import robust_scale from .data import maxabs_scale from .data import minmax_scale from .data import quantile_transform from .data import power_transform from .data import PowerTransformer from .data import PolynomialFeatures
from ._encoders import OneHotEncoder from ._encoders import OrdinalEncoder
from .label import label_binarize from .label import LabelBinarizer from .label import LabelEncoder from .label import MultiLabelBinarizer
from ._discretization import KBinsDiscretizer
from .imputation import Imputer
all = [ 'Binarizer', 'FunctionTransformer', 'Imputer', 'KBinsDiscretizer', 'KernelCenterer', 'LabelBinarizer', 'LabelEncoder', 'MultiLabelBinarizer', 'MinMaxScaler', 'MaxAbsScaler', 'QuantileTransformer', 'Normalizer', 'OneHotEncoder', 'OrdinalEncoder', 'PowerTransformer', 'RobustScaler', 'StandardScaler', 'add_dummy_feature', 'PolynomialFeatures', 'binarize', 'normalize', 'scale', 'robust_scale', 'maxabs_scale', 'minmax_scale', 'label_binarize', 'quantile_transform', 'power_transform', 'Imputer' ]
This was sorted by, https://github.com/scikit-learn/scikit-learn/issues/16152
This is related with pip installing latest verzion of scikit-learn which was pre-release 0.22rc3 version. We should use fixed version that works 0.21.3. I will create PR
How do i downgrade scikit-learn from 0.22.2 to 0.21
Thanks @AnasK95 and @subhashi it helps Cheers to all who are in hadelin machine learning course
For me I used SimpleImputer
from sklearn.impute import SimpleImputer
worked.
from sklearn.impute import SimpleImputer
imputer = SimpleImputer(missing_values = np.nan, strategy='mean') X.fit[:, 1:3] = imputer.fit_transform(X[:, 1:3]) X = X.apply(lambda x: x.fillna(x.value_counts().index[0]))
(slice(None, None, None), slice(1, 3, None))' is an invalid key
Still getting this error
ImportError: cannot import name 'MinMaxScalar' from sklearn.preprocessing .... any help?
I used from sklearn.impute import SimpleImputer imputer = SimpleImputer(strategy='median')
instead of from sklearn.preprocessing import Imputer imputer = Imputer(strategy="median")
not throwing any error
Hey there,
I just confronted similar error, and I found out the reason was version of the sciki-learn.. in the latest version , you should code as : from sklearn.impute import SimpleImputer instead of : from sklearn.preprocessing import Imputer
also note that inputs are as following: SimpleImputer(missing_values=np.nan, strategy='mean')
also regarding using np, you should summon numpy library. besides, there is no required parameter as axis=0 or 1
Describe the bug Installing the latest version of lightwood throws ImportError. I guess the issue is related to the sciki-learn.
To Reproduce Steps to reproduce the behavior:
Screenshots