Summary
Hi all, seeking for your help please, I run pycaret and saved the model and build streamlit app and when I reach the loading the model and use it to predict it gave me the error in attached pic, I create condo vertical env and the pip list as bellow:
Package Version
altair 4.2.0
ansi2html 1.8.0
appnope 0.1.3
asn1crypto 1.5.1
astor 0.8.1
asttokens 2.2.1
attrs 22.2.0
backcall 0.2.0
base58 2.1.1
blinker 1.5
boto3 1.26.70
botocore 1.29.70
cachetools 5.2.0
category-encoders 2.6.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 2.0.12
click 8.1.3
cloudpickle 2.2.1
comm 0.1.2
commonmark 0.9.1
contourpy 1.0.6
cryptography 36.0.2
cycler 0.11.0
Cython 0.29.33
dash 2.8.1
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table 5.0.0
debugpy 1.6.4
decorator 5.1.1
Deprecated 1.2.13
deprecation 2.1.0
distlib 0.3.6
entrypoints 0.4
enum-compat 0.0.3
executing 1.2.0
fastjsonschema 2.16.2
filelock 3.9.0
Flask 2.1.3
Flask-Cors 3.0.10
fonttools 4.38.0
gitdb 4.0.10
GitPython 3.1.30
greenlet 2.0.1
idna 3.4
imbalanced-learn 0.10.1
importlib-metadata 5.2.0
install 1.3.5
ipykernel 6.19.2
ipython 8.7.0
ipywidgets 8.0.4
itsdangerous 2.1.2
jedi 0.18.2
Jinja2 3.1.2
jmespath 1.0.1
joblib 1.2.0
jsonschema 4.17.3
jupyter_client 7.4.8
jupyter_core 5.1.0
jupyter-dash 0.4.2
jupyterlab-widgets 3.0.5
kaleido 0.2.1
kiwisolver 1.4.4
lightgbm 3.3.4
llvmlite 0.39.1
MarkupSafe 2.1.1
matplotlib 3.6.2
matplotlib-inline 0.1.6
nbformat 5.7.3
nest-asyncio 1.5.6
numba 0.56.4
numpy 1.23.5
orjson 3.8.6
oscrypto 1.3.0
packaging 22.0
pandas 1.4.4
parso 0.8.3
patsy 0.5.3
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.3.0
pip 23.0
pipenv 2023.2.4
platformdirs 2.6.0
plotly 5.13.0
plotly-resampler 0.8.3.1
pmdarima 2.0.2
prompt-toolkit 3.0.36
protobuf 3.20.3
psutil 5.9.4
ptyprocess 0.7.0
pure-eval 0.2.2
pyarrow 6.0.1
pycaret 3.0.0rc9
pycparser 2.21
pycryptodomex 3.16.0
pydeck 0.8.0
Pygments 2.13.0
PyJWT 2.6.0
Pympler 1.0.1
pyod 1.0.7
pyOpenSSL 22.0.0
pyparsing 3.0.9
pyrsistent 0.19.3
python-dateutil 2.8.2
pytz 2022.6
pytz-deprecation-shim 0.1.0.post0
pyzmq 24.0.1
requests 2.28.1
retrying 1.3.4
rich 12.6.0
s3transfer 0.6.0
schemdraw 0.15
scikit-learn 1.2.0
scikit-plot 0.3.7
scipy 1.10.0
seaborn 0.12.2
semver 2.13.0
setuptools 67.2.0
six 1.16.0
sklearn 0.0.post1
sktime 0.16.1
smmap 5.0.0
smogn 0.1.2
snowflake-connector-python 2.7.9
snowflake-sqlalchemy 1.2.4
SQLAlchemy 1.4.46
st-pages 0.3.0
stack-data 0.6.2
statsmodels 0.13.5
streamlit 1.18.1
streamlit-option-menu 0.3.2
tbats 1.1.2
tenacity 8.2.1
threadpoolctl 3.1.0
toml 0.10.2
toolz 0.12.0
tornado 6.2
tqdm 4.64.1
trace-updater 0.0.9
traitlets 5.7.1
typing_extensions 4.4.0
tzdata 2022.7
tzlocal 4.2
urllib3 1.26.13
validators 0.20.0
virtualenv 20.19.0
virtualenv-clone 0.5.7
watchdog 2.2.1
wcwidth 0.2.5
Werkzeug 2.1.2
wheel 0.38.4
widgetsnbextension 4.0.5
wrapt 1.14.1
xgboost 1.7.3
xxhash 3.2.0
yellowbrick 1.5
zipp 3.11.0
Steps to reproduce
Code snippet:
if st.button('Predict'):
X_test=pd.read_csv('data/X_test.csv', index_col=None)
saved_reg = load_model('regression Model')
predictions = predict_model(saved_reg, data=X_test)
st.dataframe(predictions)
If applicable, please provide the steps we should take to reproduce the error or specified behavior.
Expected behavior:
Explain what you expect to happen when you run the code above.
Actual behavior:
AttributeError: ‘SimpleImputer’ object has no attribute ‘keep_empty_features’
Traceback:
File “/usr/local/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 565, in run_script
exec(code, module.dict)
File “/Users/My_Name/Desktop/regression_model/ml_model/app/pages/04_🏈_CFB.py”, line 295, in
st.button(‘Predict’, on_click=predict(X_test))
File “/Users/My_name/Desktop/regression_model/ml_model/app/pages/04_🏈_CFB.py”, line 288, in predict
predictions = predict_model(saved_reg, data=test_df)
File “/usr/local/lib/python3.10/site-packages/pycaret/regression/functional.py”, line 1921, in predict_model
return experiment.predict_model(
File “/usr/local/lib/python3.10/site-packages/pycaret/regression/oop.py”, line 2214, in predict_model
return super().predict_model(
File “/usr/local/lib/python3.10/site-packages/pycaret/internal/pycaret_experiment/supervised_experiment.py”, line 4842, in predict_model
[f"{k}={v}" for k, v in locals().items() if k != “data”]
File “/usr/local/lib/python3.10/site-packages/pycaret/internal/pycaret_experiment/supervised_experiment.py”, line 4842, in
[f"{k}={v}" for k, v in locals().items() if k != “data”]
File “/usr/local/lib/python3.10/site-packages/sklearn/base.py”, line 238, in repr
repr = pp.pformat(self)
File “/usr/local/Cellar/python@3.10/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pprint.py”, line 157, in pformat
self._format(object, sio, 0, 0, {}, 0)
File “/usr/local/Cellar/python@3.10/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pprint.py”, line 174, in _format
rep = self._repr(object, context, level)
File “/usr/local/Cellar/python@3.10/3.10.10/Frameworks/Python.framework/Versions/3.10/lib/python3.10/pprint.py”, line 454, in _repr
repr, readable, recursive = self.format(object, context.copy(),
File “/usr/local/lib/python3.10/site-packages/sklearn/utils/_pprint.py”, line 189, in format
return _safe_repr(
File “/usr/local/lib/python3.10/site-packages/sklearn/utils/_pprint.py”, line 452, in _safe_repr
vrepr, vreadable, vrecur = saferepr(
File “/usr/local/lib/python3.10/site-packages/sklearn/utils/_pprint.py”, line 419, in _safe_repr
orepr, oreadable, orecur = _safe_repr(
File “/usr/local/lib/python3.10/site-packages/sklearn/utils/_pprint.py”, line 419, in _safe_repr
orepr, oreadable, orecur = _safe_repr(
File “/usr/local/lib/python3.10/site-packages/sklearn/utils/_pprint.py”, line 452, in _safe_repr
vrepr, vreadable, vrecur = saferepr(
File “/usr/local/lib/python3.10/site-packages/sklearn/utils/_pprint.py”, line 440, in _safe_repr
params = _changed_params(object)
File “/usr/local/lib/python3.10/site-packages/sklearn/utils/_pprint.py”, line 93, in _changed_params
params = estimator.get_params(deep=False)
File “/usr/local/lib/python3.10/site-packages/sklearn/base.py”, line 170, in get_params
value = getattr(self, key)
Debug info
- Streamlit version: 1.18.1
- Python version: 3.8.16
- Pycaret version: 3.0.0rc9
- Using Conda virtual env
- OS version: macOS Monterey 12.6
- Browser version: safari 16.2
Requirements file
Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.
Links
- Link to your GitHub repo:
- Link to your deployed app:
Additional information
the same saved model I used out of streamlit and it worked as expected and I was able to load it and use to predict
Thanks help please