ImportError: cannot import name '_gb_losses' from 'sklearn.ensemble' ; Error deploying ML python webapp to streamlit community cloud

49 views Asked by At

Out put below from the install log:
2024-03-13 00:11:02.729 Uncaught app exception Traceback (most recent call last): File "/home/adminuser/venv/lib/python3.9/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 542, in _run_script exec(code, module.dict) File "/mount/src/campusplacementmlapp/Campus_Placement_ML_Webapp.py", line 12, in import sklearn_json as skljson File "/home/adminuser/venv/lib/python3.9/site-packages/sklearn_json/init.py", line 1, in from sklearn_json import classification as clf File "/home/adminuser/venv/lib/python3.9/site-packages/sklearn_json/classification.py", line 7, in from sklearn.ensemble import RandomForestClassifier, GradientBoostingClassifier, _gb_losses ImportError: cannot import name '_gb_losses' from 'sklearn.ensemble' (/home/adminuser/venv/lib/python3.9/site-packages/sklearn/ensemble/init.py)

I tried streamlit webapp deployment on my local machine and it worked like a charm but when I tried to deploy it on streamlit community cloud, running into issues with internal dependencies.

I need sklearn_json to load a pre-built Logistic Regression model. As I ran into import issue with sklearn package install, I tried to move to joblib but similar issues with dependencies.

Has anyone encountered similar issues? I tried to google the error but in vain for this particular issue. By the way, I was able to deploy a XGBoost app without any issues on streamlit community cloud.

Please help me resolve this import error to go forward on my webapp deployment.

Requirements for the install

pandas sklearn_json

main python file contains these import statements

import pandas as pd import streamlit as st import sklearn_json as skljson

0

There are 0 answers