Skip to content

[BUG]: finalize_model() logs wrong model.pkl to mlflow #3496

@hakan-77

Description

@hakan-77

pycaret version checks

Issue Description

Calling finalize_model() with logging turned on logs a model.pkl that predicts completely random values (dummy?)

Reproducible Example

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

data = get_data('ice_cream')

exp = RegressionExperiment()

exp.setup(data, target="Revenue", log_experiment=True, experiment_name="test")
model = exp.compare_models()
model = exp.create_model(model)

model = exp.tune_model(model)
# up until this point model.pkl files are correct on mlflow

model = exp.finalize_model(model)  
# wrong .pkl gets logged
# downloading .pkl from mlflow and predicting gives random looking values 

exp.save_model(model)  
# correct model.pkl gets saved on disk

Expected Behavior

finalize_model() logs the correct model.pkl file

Actual Results

Temperature	Revenue		prediction_label
0	19.024611	517.534058	36.612213
1	8.790953	237.763916	10.010834
2	18.233229	418.137268	34.555084
3	35.628925	809.463440	79.773499
4	22.284550	550.278503	45.086090
5	16.302555	381.564148	29.536499
6	12.688430	276.787079	20.141968
7	16.020975	372.990601	28.804535
8	23.761436	553.445312	48.925140

Installed Versions

System: python: 3.8.16 (default, Mar 1 2023, 21:19:10) [Clang 14.0.6 ] executable: /Users/hakan/.conda/envs/myenv/bin/python3 machine: macOS-10.16-x86_64-i386-64bit PyCaret required dependencies: pip: 23.0.1 setuptools: 66.0.0 pycaret: 3.0.0 IPython: 8.12.0 ipywidgets: 8.0.6 tqdm: 4.65.0 numpy: 1.23.5 pandas: 1.5.3 jinja2: 3.1.2 scipy: 1.9.1 joblib: 1.2.0 sklearn: 1.2.2 pyod: 1.0.9 imblearn: 0.10.1 category_encoders: 2.6.0 lightgbm: 3.3.5 numba: 0.56.4 requests: 2.28.2 matplotlib: 3.7.1 scikitplot: 0.3.7 yellowbrick: 1.5 plotly: 5.14.1 kaleido: 0.2.1 statsmodels: 0.13.5 sktime: 0.17.0 tbats: 1.1.3 pmdarima: 2.0.3 psutil: 5.9.5

PyCaret optional dependencies:
shap: 0.41.0
interpret: 0.3.2
umap: Not installed
pandas_profiling: Not installed
explainerdashboard: Not installed
autoviz: Not installed
fairlearn: 0.8.0
xgboost: 1.7.5
catboost: 1.1.1
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.3.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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingmlflowTopics related to MLFlow

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions