Deploy App Streamlit cloud doesn´t show my ML result

I developed an ML algorithm (Decision tree classifier) ​​where the result is a risk probability. This probability is fully functional in my development and testing environment but when I deploy it in Streamlit Cloud, the probability result is not shown but the others modules are fully functional, do you have any idea what causes the problem?

Hey @ElthonD,

Thanks for sharing this question! Could you please also share a link to your deployed app and a link to the app’s GitHub repo?

Hi Caroline,

Yes, sure:

App:

Github repo:

On which pages are the results not being shown (that are being shown when you run the app locally)?

Hi Caroline, the second page “% Probabilidad de Robo”. You can replicate this data in Excel so you can carry out the test.

I would suggest adding some print and st.write statements to help debug what is happening, and check the log to see if there are any errors or warnings while running the deployed app.

The only thing that stands out quickly from your code is that you’re relying on the global variable uploaded_file, rather than explicitly passing it as an argument.
e.g.

entrada_datos = df_proba_robo(uploaded_file)

I’m not sure why that would necessarily cause issues, but I would suggest making that change, and printing out the value of uploaded_file along the way so you can see if it’s getting passed in and transformed correctly.

1 Like

Hi,

Thanks for the recommendation and yes, I was doing it that way but the entire data frame disappears just when the prediction model loads.

I have tried just running it by placing a button, I have added your recommendation, I have tried placing the model loading function in the model algorithm and I have imported it and in all the attempts the result of the prediction is not shown and the curious thing is that when I run the app without deploying and it works perfectly.

I just don’t understand what happens with the deployment in streamlit cloud.

The only thing I can think of in general is that you do have some unpinned dependencies, including streamlit itself – you might try pinning all your dependencies to specific versions and making sure those versions are installed locally, and then see what cloud does.

Hello,

Thanks for the feedback.

I didn’t understand what you mentioned as unpinned dependencies. Are you referring to the references of the library versions in the requirements file? Could you give me an example?

I mean the requirments.txt file.

Right now, for example, it just has streamlit, and that might be a different version locally and on SiS. If you add a specific version, like

streamlit==1.27.0

Ideally I try not to pin every dependency, but since you’re having issues with differences between local and Cloud, this seems like a likely reason.

You can do pip freeze to see exactly what you have installed locally.

Hello,

Yes, I have already checked all the versions of my installed libraries. I performed tests with both, pinned dependencies and unpinned dependencies and in both tests the result is the same: The results of the classification model are not shown but in my local environment it works perfectly.

I will continue looking for other options.

Thank you.

So sorry – that’s the best guess I can come up for why there would be a difference on cloud vs local.

Hello,

I made several browser changes, debugging front-end content and without favorable results.

I will close the topic because the solution was to deploy it on another platform other than streamlit cloud and it works perfectly.

Thanks for the support.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.