MinMaxScaler from sklearn throwing error after deployment

Hello, I am newer to streamlit, please forgive me this is also my first time posting on a technical forum, however this one is driving me crazy.

So created a streamlit app for League of Legends as a capstone for a bootcamp, I am using a MinMaxScaler on collected data from the Riot API, prior to predicting the outcome with a Decision Tree. In my local environment it works flawlessly (after many hours of pulling my hair out). However, once I deployed the code I began getting errors with my MinMaxScaler. This scaler was built and fit in a Jupyter Notebook and saved as a .gz utilizing the joblib package. I load this into my streamlit code utilizing joblib as well. Once my main function runs it throws an error for the scaling function:

AttributeError: 'MinMaxScaler' object has no attribute 'clip'
Traceback:
File "/usr/local/lib/python3.7/site-packages/streamlit/script_runner.py", line 332, in _run_script
    exec(code, module.__dict__)
File "/app/league_capstone/Streamlit_App.py", line 23, in <module>
    summoner_data_x, summoner_data_y, summoner_data_raw= full_process(user_input, scaler, games)
File "/app/league_capstone/Util.py", line 212, in full_process
    team_data_x = scale_data(team_data_summoners, scaler, summonerName)
File "/app/league_capstone/Util.py", line 200, in scale_data
    X_num_scaled = scaler.transform(X_num)
File "/home/appuser/.local/lib/python3.7/site-packages/sklearn/preprocessing/_data.py", line 439, in transform
    if self.clip:

What I find strange is that this runs smoothly locally, but once it was deployed there are errors. Any help would be appreciated. I will leave the link to the app, and github repo below.

requirements.txt:

matplotlib==3.3.3
seaborn==0.11.0
plotly==4.14.1
pandas==1.1.5
xgboost==1.3.0.post0
riotwatcher==3.1.1
numpy==1.19.3
streamlit==0.73.0
joblib==1.0.0
imbalanced_learn==0.7.0
imblearn==0.0
scikit_learn==0.24.0

https://share.streamlit.io/luxorth1/league_capstone/main/Streamlit_App.py

1 Like

It would seem that when I exported my requirements.txt it did not match my local environment for some reason. This is resolved.

2 Likes

Hey @Luxorth1!

First, Welcome to the Streamlit community! :partying_face: :partying_face: :partying_face: :partying_face: :partying_face: :tada:

Because we care approaching the holidays many of our team and community members are already on vacation! I’m sorry you were having trouble, but I am very glad you were able to figure it out!

If you want to show off the app you made, you can post on the forum under the “show the community” tab! We always love to see the apps that the community makes!

Happy Streamlit-ing!
Marisa

1 Like