Different predictions between Streamlit and Jupyter Notebook

Hello everyone,
This is my first attempt with Streamlit; I’m trying to build an interactive salary prediction web app.
The Streamlit app provides different predictions in comparison with Jupyter Notebook. Have you got any idea why this issue occurred?

Screenshot from 2022-08-14 19-45-43

I have this exact same issue @Isaak_Karagiannidis, did you figure it out? It was also giving me different predictions on my running the streamline app on local machine vs. on the web. So, my local machine and Jupyter Notebook were the same, but the web app was different. It also happened seemingly randomly, all three were the same and then the web app changed (giving different accuracy percentage for the prediction model, and also giving different predictions than Jupypter and local machine)

This isn’t showing anything useful to debug your issue. Can you show the code for how rfr2 is built?

Hello Mariana,
My problem was the different order of the features for transformation (encoding) in the Jupyter and VS Code. When I put them in the same order the predictions are still the same. In case you are using encoders for transformation check the order of the features.

Great. When writing Jupyter notebooks, it’s always a good idea to be aware of execution order and ensuring you wrap state mutators in functions, so that when you convert to a script (to run in Streamlit, for example), the correct execution order is preserved.

Thank you for your reply @Isaak_Karagiannidis! I had looked at that issue for mine, but that didn’t solve it. Just to help anyone out there who may be struggling with this issue:
What caused my problem: changing the csv dataset I trained and pickled my model on by 2 rows on the Github repository attached to the project and also on my local machine, but not changing the .pkl file on GitHub after that fact.
I’m still pretty new to git and GitHub in general, so I believe I was getting different predictions and r2 values and predictions because the .pkl file in GitHub was still the original .pkl file before I changed the csv.
After I pushed the entire project again to a new repository the r^2 and prediction values in Jupyter, local machine, and app were all the same.
Thank you!

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