shankarpandala / lazypredict

Lazy Predict help build a lot of basic models without much code and helps understand which models works better without any parameter tuning
MIT License
3k stars 344 forks source link

OneHotEncoder.__init__() got an unexpected keyword argument 'sparse #454

Open minivillalba4 opened 3 months ago

minivillalba4 commented 3 months ago

When I execute this line of code on Jupiter Notebook this is what happens:

from lazypredict.Supervised import LazyClassifier


TypeError Traceback (most recent call last) Cell In[1], line 6 4 import matplotlib.pyplot as plt 5 from sklearn.model_selection import train_test_split,RandomizedSearchCV ----> 6 from lazypredict.Supervised import LazyClassifier 7 from sklearn.preprocessing import MinMaxScaler

File ~\anaconda3\Lib\site-packages\lazypredict\Supervised.py:98 89 # CLASSIFIERS.append(('CatBoostClassifier',catboost.CatBoostClassifier)) 91 numeric_transformer = Pipeline( 92 steps=[("imputer", SimpleImputer(strategy="mean")), ("scaler", StandardScaler())] 93 ) 95 categorical_transformer_low = Pipeline( 96 steps=[ 97 ("imputer", SimpleImputer(strategy="constant", fill_value="missing")), ---> 98 ("encoding", OneHotEncoder(handle_unknown="ignore", sparse=False)), 99 ] 100 ) 102 categorical_transformer_high = Pipeline( 103 steps=[ 104 ("imputer", SimpleImputer(strategy="constant", fill_value="missing")), (...) 107 ] 108 ) 111 # Helper function

TypeError: OneHotEncoder.init() got an unexpected keyword argument 'sparse'

balachandragv commented 3 months ago

Hi.. Changing 'sparse' to 'sparse_output' will resolve the issue.