Spaces:
Sleeping
Sleeping
adjoint-bass
commited on
Commit
•
af5a939
1
Parent(s):
ac54e04
update
Browse files- __pycache__/functions.cpython-39.pyc +0 -0
- app.py +3 -4
- functions.py +6 -6
__pycache__/functions.cpython-39.pyc
ADDED
Binary file (4.85 kB). View file
|
|
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 |
|
@@ -49,8 +49,7 @@ fancy_header("Making AQI predictions for the next 7 days")
|
|
49 |
|
50 |
preds = model.predict(data_encoder(weekly_data)).astype(int)
|
51 |
|
52 |
-
|
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,6 +57,6 @@ next_week_str = [f"{days.strftime('%A')}, {days.strftime('%Y-%m-%d')}" for days
|
|
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
|
62 |
|
63 |
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_info
|
7 |
from PIL import Image
|
8 |
|
9 |
|
|
|
49 |
|
50 |
preds = model.predict(data_encoder(weekly_data)).astype(int)
|
51 |
|
52 |
+
color_level, poll_level = get_info(preds.reshape(1, -1))
|
|
|
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 |
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")
|
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 = ['Good', 'Moderate', 'Unhealthy for sensitive Groups','Unhealthy' ,'Very Unhealthy', 'Hazardous']
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
return
|
|
|
172 |
level = [table[el] for el in cat[1]]
|
173 |
return level
|
174 |
|
175 |
+
def get_info(level:list):
|
176 |
+
air_pollution_level = {1:[50, 'Good', 'Green'], 2:[100, 'Moderate','Yellow'], 3:[150, 'Unhealthy for sensitive Groups','DarkOrange'],4:[200, 'Unhealthy','Red'] ,5:[300, 'Very Unhealthy','Purple'], 6:[1000, 'Hazardous','DarkRed']}
|
177 |
+
ind = [np.max(np.nonzero( el >= [air_pollution_level[key][0] for key in air_pollution_level.keys()])) for el in level]
|
178 |
+
color_text = [f"color:{air_pollution_level[idex][2]};" for idex in ind]
|
179 |
+
pollution_level = [air_pollution_level[idex][1] for idex in ind]
|
180 |
+
return color_text, pollution_level
|