Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I am facing this issue while importing lazypredict #456

Open
iammuhammadnoumankhan opened this issue Sep 11, 2024 · 7 comments
Open

I am facing this issue while importing lazypredict #456

iammuhammadnoumankhan opened this issue Sep 11, 2024 · 7 comments

Comments

@iammuhammadnoumankhan
Copy link

iammuhammadnoumankhan commented Sep 11, 2024

Actually, i was importing lazy predict version 0.2.12 and sklearn==1.5.1

i got this issue


TypeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 from lazypredict.Supervised import LazyClassifier
2 from sklearn.model_selection import train_test_split

File ~\anaconda3\envs\base_env\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'

@qzc438
Copy link

qzc438 commented Sep 20, 2024

I have the same issue.

@lesshaste
Copy link

It seems to be a scikit learn version problem. See https://stackoverflow.com/a/77997362/1473517 . Lazypredict needs updating but I don't know if anyone is still maintaining.

@iammuhammadnoumankhan
Copy link
Author

iammuhammadnoumankhan commented Sep 22, 2024 via email

@iammuhammadnoumankhan
Copy link
Author

iammuhammadnoumankhan commented Sep 22, 2024 via email

@MrIsCM
Copy link

MrIsCM commented Sep 29, 2024

Hello,

The issue is related to Scikit-learn version changes. From scikit-learn documentation:

Added in version 1.2: sparse was renamed to sparse_output

It appears they changed the keyword 'sparse' to 'sparse_output'.
The solution would simply be to change the old keyword to the new one.

Edit:
It looks like this has been fixed in the code (I see an update 7 months ago).
However, the latest release was 28th September 2022.

@CoryKornowicz
Copy link

I got past this issue by installing from git through pip.
pip install git+https://github.com/shankarpandala/lazypredict.git
This grabbed the latest fixes that support the new "sparse_output" naming.

@jorobledo
Copy link

Worst case, just open the file in your error message (~\anaconda3\envs\base_env\Lib\site-packages\lazypredict\Supervised.py:98):

File ~\anaconda3\envs\base_env\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)),

And errase the , sparse=False from line 98.

Then just restart your kernel if you are within jupyter notebook, and voilá

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants