Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -16,14 +16,13 @@ fs = project.get_feature_store()
|
|
16 |
|
17 |
|
18 |
def air_quality(city):
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
weather_df
|
25 |
-
|
26 |
-
#weather_df = weather_df.drop(columns=["precipprob", "uvindex", "date","city","conditions"]).fillna(0)
|
27 |
weather_df.drop(['tempmax'], inplace = True, axis = 1)
|
28 |
weather_df.drop('tempmin', inplace = True, axis = 1)
|
29 |
weather_df.drop('feelslikemax', inplace = True, axis = 1)
|
@@ -40,18 +39,20 @@ def air_quality(city):
|
|
40 |
weather_df.drop('solarradiation', inplace = True, axis = 1)
|
41 |
weather_df.drop('solarenergy', inplace = True, axis = 1)
|
42 |
weather_df.drop('pressure', inplace = True, axis = 1)
|
43 |
-
|
|
|
|
|
44 |
mr = project.get_model_registry()
|
45 |
model = mr.get_model("aqi_model_gb", version=1)
|
46 |
model_dir = model.download()
|
47 |
model = joblib.load(model_dir + "/gb_model.pkl")
|
48 |
-
|
49 |
preds = model.predict(weather_df)
|
50 |
-
|
51 |
predictions = ''
|
52 |
for k in range(7):
|
53 |
predictions += "Predicted AQI on " + (datetime.now() + timedelta(days=k)).strftime('%Y-%m-%d') + ": " + str(int(preds[k]))+"\n"
|
54 |
-
|
55 |
print(predictions)
|
56 |
return predictions
|
57 |
|
@@ -62,4 +63,4 @@ description="Input a value to get next weeks AQI prediction for London", inputs=
|
|
62 |
|
63 |
|
64 |
if __name__ == "__main__":
|
65 |
-
demo.launch()
|
|
|
16 |
|
17 |
|
18 |
def air_quality(city):
|
19 |
+
weather_df = pd.DataFrame()
|
20 |
+
for i in range(8):
|
21 |
+
weather_data = get_weather_df([get_weather_data("Helsinki",(datetime.now() + timedelta(days=i)).strftime("%Y-%m-%d"))])
|
22 |
+
weather_df = weather_df.append(weather_data)
|
23 |
+
|
24 |
+
#weather_df = weather_df.drop(columns=["tempmax", "tempmin", "feelslikemax", "feelslikemin", "feelslike", "dew", "precipprob", "precipcover", "snow", "snowdepth", "windgust", "windspeed", "winddir", "solarradiation","solarenergy","pressure"]).fillna(0)
|
25 |
+
|
|
|
26 |
weather_df.drop(['tempmax'], inplace = True, axis = 1)
|
27 |
weather_df.drop('tempmin', inplace = True, axis = 1)
|
28 |
weather_df.drop('feelslikemax', inplace = True, axis = 1)
|
|
|
39 |
weather_df.drop('solarradiation', inplace = True, axis = 1)
|
40 |
weather_df.drop('solarenergy', inplace = True, axis = 1)
|
41 |
weather_df.drop('pressure', inplace = True, axis = 1)
|
42 |
+
|
43 |
+
weather_df = data_encoder(weather_df)
|
44 |
+
|
45 |
mr = project.get_model_registry()
|
46 |
model = mr.get_model("aqi_model_gb", version=1)
|
47 |
model_dir = model.download()
|
48 |
model = joblib.load(model_dir + "/gb_model.pkl")
|
49 |
+
|
50 |
preds = model.predict(weather_df)
|
51 |
+
|
52 |
predictions = ''
|
53 |
for k in range(7):
|
54 |
predictions += "Predicted AQI on " + (datetime.now() + timedelta(days=k)).strftime('%Y-%m-%d') + ": " + str(int(preds[k]))+"\n"
|
55 |
+
|
56 |
print(predictions)
|
57 |
return predictions
|
58 |
|
|
|
63 |
|
64 |
|
65 |
if __name__ == "__main__":
|
66 |
+
demo.launch()
|