Spaces:
Sleeping
Sleeping
adjoint-bass
commited on
Commit
•
174811d
1
Parent(s):
af5a939
revert back
Browse files- app.py +5 -4
- functions.py +6 -6
app.py
CHANGED
@@ -3,7 +3,7 @@ import hopsworks
|
|
3 |
import joblib
|
4 |
import pandas as pd
|
5 |
import datetime
|
6 |
-
from functions import get_weather_data_weekly, data_encoder,
|
7 |
from PIL import Image
|
8 |
|
9 |
|
@@ -14,7 +14,7 @@ def fancy_header(text, font_size=24):
|
|
14 |
st.set_page_config(layout="wide")
|
15 |
st.title('Air Quality Prediction Project for Vienna! 🌩')
|
16 |
vienna_image = Image.open('vienna.jpg')
|
17 |
-
st.image(vienna_image, use_column_width='auto'
|
18 |
st.write(36 * "-")
|
19 |
|
20 |
st.markdown("# This is a final project in the course ID2223 Scalable Machine Learning and Deep Learning :computer:")
|
@@ -49,7 +49,8 @@ fancy_header("Making AQI predictions for the next 7 days")
|
|
49 |
|
50 |
preds = model.predict(data_encoder(weekly_data)).astype(int)
|
51 |
|
52 |
-
|
|
|
53 |
|
54 |
next_week_datetime = [today + datetime.timedelta(days=d) for d in range(7)]
|
55 |
next_week_str = [f"{days.strftime('%A')}, {days.strftime('%Y-%m-%d')}" for days in next_week_datetime]
|
@@ -57,6 +58,6 @@ next_week_str = [f"{days.strftime('%A')}, {days.strftime('%Y-%m-%d')}" for days
|
|
57 |
df = pd.DataFrame(data=[preds, poll_level], index=["AQI", "Air pollution level"], columns=next_week_str)
|
58 |
|
59 |
st.write("Here they are!")
|
60 |
-
st.dataframe(df)
|
61 |
|
62 |
st.button("Re-run")
|
|
|
3 |
import joblib
|
4 |
import pandas as pd
|
5 |
import datetime
|
6 |
+
from functions import get_weather_data_weekly, data_encoder, get_aplevel, get_color
|
7 |
from PIL import Image
|
8 |
|
9 |
|
|
|
14 |
st.set_page_config(layout="wide")
|
15 |
st.title('Air Quality Prediction Project for Vienna! 🌩')
|
16 |
vienna_image = Image.open('vienna.jpg')
|
17 |
+
st.image(vienna_image, use_column_width='auto')
|
18 |
st.write(36 * "-")
|
19 |
|
20 |
st.markdown("# This is a final project in the course ID2223 Scalable Machine Learning and Deep Learning :computer:")
|
|
|
49 |
|
50 |
preds = model.predict(data_encoder(weekly_data)).astype(int)
|
51 |
|
52 |
+
air_pollution_level = ['Good', 'Moderate', 'Unhealthy for sensitive Groups','Unhealthy' ,'Very Unhealthy', 'Hazardous']
|
53 |
+
poll_level = get_aplevel(preds.T.reshape(-1, 1), air_pollution_level)
|
54 |
|
55 |
next_week_datetime = [today + datetime.timedelta(days=d) for d in range(7)]
|
56 |
next_week_str = [f"{days.strftime('%A')}, {days.strftime('%Y-%m-%d')}" for days in next_week_datetime]
|
|
|
58 |
df = pd.DataFrame(data=[preds, poll_level], index=["AQI", "Air pollution level"], columns=next_week_str)
|
59 |
|
60 |
st.write("Here they are!")
|
61 |
+
st.dataframe(df.style.apply(get_color, subset=(["Air pollution level"], slice(None))))
|
62 |
|
63 |
st.button("Re-run")
|
functions.py
CHANGED
@@ -172,9 +172,9 @@ def get_aplevel(temps:np.ndarray, table:list):
|
|
172 |
level = [table[el] for el in cat[1]]
|
173 |
return level
|
174 |
|
175 |
-
def
|
176 |
-
air_pollution_level =
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
return
|
|
|
172 |
level = [table[el] for el in cat[1]]
|
173 |
return level
|
174 |
|
175 |
+
def get_color(level:list):
|
176 |
+
air_pollution_level = ['Good', 'Moderate', 'Unhealthy for sensitive Groups','Unhealthy' ,'Very Unhealthy', 'Hazardous']
|
177 |
+
color_list = ["Green", "Yellow", "DarkOrange", "Red", "Purple", "DarkRed"]
|
178 |
+
ind = [air_pollution_level.index(lel) for lel in level]
|
179 |
+
text = [f"color:{color_list[idex]};" for idex in ind]
|
180 |
+
return text
|