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
2.87k stars 333 forks source link

scikit-learn version issue #446

Open Ezzaldin97 opened 7 months ago

Ezzaldin97 commented 7 months ago

Description: There is an issue with OneHotEncoder, as it isn't accepting argument 'sparse'

explanation: recent versions of OneHotEncoder Object changed the 'sparse' argument to 'sparse_output', so this error is because of the issue in the dependencies version.

solution: this can be solved either by limiting the versions of the dependencies or handling the code to match the recent versions.

issue:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], [line 1](vscode-notebook-cell:?execution_count=2&line=1)
----> [1](vscode-notebook-cell:?execution_count=2&line=1) from lazypredict.Supervised import LazyRegressor

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

TypeError: OneHotEncoder.__init__() got an unexpected keyword argument 'sparse'
nityansuman commented 7 months ago

Fixed here: https://github.com/nityansuman/lazypredict-nightly (PYPI: pip install lazypredict-nightly) @Ezzaldin97

Ezzaldin97 commented 7 months ago

Thanks @nityansuman 🙏

SyedRizvi786092 commented 3 months ago

I am facing the same issue too :(

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[2], line 4
      2 import numpy as np  # linear algebra
      3 import pandas as pd  # data processing, CSV file I/O
----> 4 from lazypredict.Supervised import LazyRegressor
      5 from sklearn.model_selection import train_test_split
      6 from sklearn.preprocessing import LabelEncoder

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'