8000 [BUG]: TypeError: create_model() got multiple values for argument 'estimator' · Issue #4071 · pycaret/pycaret · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

[BUG]: TypeError: create_model() got multiple values for argument 'estimator' #4071

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

Open
3 tasks done
K021 opened this issue Sep 11, 2024 · 0 comments · May be fixed by #4072
Open
3 tasks done

[BUG]: TypeError: create_model() got multiple values for argument 'estimator' #4071

K021 opened this issue Sep 11, 2024 · 0 comments · May be fixed by #4072
Labels
bug Something isn't working

Comments

@K021
Copy link
K021 commented Sep 11, 2024

pycaret version checks

Issue Description

The create_model method for RegressionExperiment accepts **kwargs for estimator parameters. However, some of the estimator parameters share the same name as the arguments in the create_model() method itself. This results in errors such as:

TypeError: create_model() got multiple values for argument 'estimator'
image

Reproducible Example

from pycaret.datasets import get_data
from pycaret.regression import RegressionExperiment

data = get_data('insurance')

exp = RegressionExperiment()
exp.setup(data, target = 'charges', session_id = 123)

model = exp.compare_models()

lb = exp.get_leaderboard(model_only=True)
lb_dict = {row["Model Name"]: row["Model"] for _, row in lb.iterrows()}

ada_model = lb_dict["AdaBoost Regressor"]
ada_model_params = ada_model.get_params()
print(ada_model_params)

created_model = exp.create_model("ada", **ada_model_params)

Expected Behavior

Succeeded in using exp.create_model("ada", **ada_model_params).

Actual Results

age     sex     bmi  children smoker     region      charges
0   19  female  27.900         0    yes  southwest  16884.92400
1   18    male  33.770         1     no  southeast   1725.55230
2   28    male  33.000         3     no  southeast   4449.46200
3   33    male  22.705         0     no  northwest  21984.47061
4   32    male  28.880         0     no  northwest   3866.85520
                    Description             Value
0                    Session id               123
1                        Target           charges
2                   Target type        Regression
3           Original data shape         (1338, 7)
4        Transformed data shape        (1338, 10)
5   Transformed train set shape         (936, 10)
6    Transformed test set shape         (402, 10)
7              Numeric features                
8FEC
 3
8          Categorical features                 3
9                    Preprocess              True
10              Imputation type            simple
11           Numeric imputation              mean
12       Categorical imputation              mode
13     Maximum one-hot encoding                25
14              Encoding method              None
15               Fold Generator             KFold
16                  Fold Number                10
17                     CPU Jobs                -1
18                      Use GPU             False
19               Log Experiment             False
20              Experiment Name  reg-default-name
21                          USI              3b22
                                    Model        MAE           MSE  \
gbr           Gradient Boosting Regressor  2701.9927  2.354898e+07
rf                Random Forest Regressor  2771.4583  2.541650e+07
lightgbm  Light Gradient Boosting Machine  2992.1828  2.552104e+07
et                  Extra Trees Regressor  2833.3624  2.842784e+07
ada                    AdaBoost Regressor  4316.0568  2.922051e+07
lar                Least Angle Regression  4303.5559  3.838806e+07
llar         Lasso Least Angle Regression  4303.7694  3.838682e+07
br                         Bayesian Ridge  4311.2349  3.839195e+07
ridge                    Ridge Regression  4317.6984  3.839644e+07
lasso                    Lasso Regression  4303.7697  3.838680e+07
lr                      Linear Regression  4303.5559  3.838806e+07
huber                     Huber Regressor  3464.2446  4.887885e+07
dt                Decision Tree Regressor  3383.4916  4.782320e+07
par          Passive Aggressive Regressor  4537.0122  6.734631e+07
en                            Elastic Net  7372.5238  9.045078e+07
omp           Orthogonal Matching Pursuit  9089.9268  1.334394e+08
knn                 K Neighbors Regressor  8001.2492  1.313401e+08
dummy                     Dummy Regressor  9192.5418  1.485168e+08

                RMSE      R2   RMSLE    MAPE  TT (Sec)
gbr        4832.9682  0.8320  0.4447  0.3137     0.013
rf         5028.6343  0.8172  0.4690  0.3303     0.024
lightgbm   5042.0978  0.8149  0.5378  0.3751     0.313
et         5305.6516  0.7991  0.4877  0.3363     0.021
ada        5398.4561  0.7903  0.6368  0.7394     0.008
lar        6176.5920  0.7306  0.5949  0.4433     0.007
llar       6176.4846  0.7306  0.5952  0.4434     0.007
br         6176.8896  0.7306  0.5910  0.4447     0.007
ridge      6177.2329  0.7306  0.5891  0.4459     0.158
lasso      6176.4824  0.7306  0.5952  0.4434     0.142
lr         6176.5920  0.7306  0.5949  0.4433     0.238
huber      6969.1873  0.6539  0.4908  0.2210     0.008
dt         6895.7016  0.6497  0.5602  0.4013     0.007
par        8142.7826  0.5422  0.5276  0.3207     0.008
en         9468.3193  0.3792  0.7342  0.9184     0.007
omp       11488.4238  0.0884  0.8790  1.1514     0.007
knn       11423.2734  0.0862  0.8533  0.9225     0.008
dummy     12132.4733 -0.0175  1.0154  1.5637     0.006
{'estimator': None, 'learning_rate': 1.0, 'loss': 'linear', 'n_estimators': 50, 'random_state': 123}
Traceback (most recent call last):
  File "/Users/jooeon/projects/learnings/python/pycaret/bug.py", line 18, in <module>
    created_model = exp.create_model("ada", **ada_model_params)
TypeError: create_model() got multiple values for argument 'estimator'

Installed Versions

System: python: 3.9.19 (main, Jun 24 2024, 07:09:21) [Clang 15.0.0 (clang-1500.1.0.2.5)] executable: /Users/jooeon/.pyenv/versions/3.9.19/envs/learnings-pycaret/bin/python machine: macOS-14.2.1-arm64-arm-64bit

PyCaret required dependencies:
pip: 23.0.1
setuptools: 74.0.0
pycaret: 3.3.2
IPython: 8.18.1
ipywidgets: 8.1.5
tqdm: 4.66.5
numpy: 1.26.4
pandas: 2.1.4
jinja2: 3.1.4
scipy: 1.11.4
joblib: 1.3.2
sklearn: 1.4.2
pyod: 2.0.1
imblearn: 0.12.3
category_encoders: 2.6.3
lightgbm: 4.5.0
numba: 0.60.0
requests: 2.32.3
matplotlib: 3.7.5
scikitplot: 0.3.7
yellowbrick: 1.5
plotly: 5.23.0
plotly-resampler: Not installed
kaleido: 0.2.1
schemdraw: 0.15
statsmodels: 0.14.2
sktime: 0.26.0
tbats: 1.1.3
pmdarima: 2.0.4
psutil: 6.0.0
markupsafe: 2.1.5
pickle5: Not installed
cloudpickle: 3.0.0
deprecation: 2.1.0
xxhash: 3.5.0
wurlitzer: 3.1.1

PyCaret optional dependencies:
shap: Not installed
interpret: Not installed
umap: Not installed
ydata_profiling: Not installed
explainerdashboard: Not installed
autoviz: Not installed
fairlearn: Not installed
deepchecks: Not installed
xgboost: Not installed
catboost: Not installed
kmodes: Not installed
mlxtend: Not installed
statsforecast: Not installed
tune_sklearn: Not installed
ray: Not installed
hyperopt: Not installed
optuna: Not installed
skopt: Not installed
mlflow: 2.16.0
gradio: Not installed
fastapi: Not installed
uvicorn: Not installed
m2cgen: Not installed
evidently: Not installed
fugue: Not installed
streamlit: Not installed
prophet: Not installed

@K021 K021 added the bug Something isn't working label Sep 11, 2024
@K021 K021 linked a pull request Sep 12, 2024 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant
0