Spaces:
Build error
Build error
Delete app.py
Browse files
app.py
DELETED
@@ -1,99 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import hopsworks
|
3 |
-
import joblib
|
4 |
-
import pandas as pd
|
5 |
-
import numpy as np
|
6 |
-
import json
|
7 |
-
import time
|
8 |
-
from datetime import timedelta, datetime
|
9 |
-
|
10 |
-
|
11 |
-
from functions import *
|
12 |
-
|
13 |
-
|
14 |
-
project = hopsworks.login()
|
15 |
-
fs = project.get_feature_store()
|
16 |
-
|
17 |
-
feature_view = fs.get_feature_view(
|
18 |
-
name = 'air_quality_fv',
|
19 |
-
version = 3
|
20 |
-
)
|
21 |
-
|
22 |
-
|
23 |
-
def air_quality(city):
|
24 |
-
weather_df = pd.DataFrame()
|
25 |
-
for i in range(8):
|
26 |
-
weather_data = get_weather_df([get_weather_data((datetime.now() + timedelta(days=i)).strftime("%Y-%m-%d"))])
|
27 |
-
weather_df = weather_df.append(weather_data)
|
28 |
-
|
29 |
-
weather_df = weather_df.drop(columns=["date"]).fillna(0)
|
30 |
-
|
31 |
-
mr = project.get_model_registry()
|
32 |
-
model = mr.get_model("gradient_boost_model", version=1)
|
33 |
-
model_dir = model.download()
|
34 |
-
model = joblib.load(model_dir + "/model.pkl")
|
35 |
-
|
36 |
-
preds = model.predict(weather_df)
|
37 |
-
|
38 |
-
predictions = ''
|
39 |
-
for k in range(7):
|
40 |
-
predictions += "Predicted AQI on " + (datetime.now() + timedelta(days=k)).strftime('%Y-%m-%d') + ": " + str(int(preds[k]))+"\n"
|
41 |
-
|
42 |
-
print(predictions)
|
43 |
-
return predictions
|
44 |
-
|
45 |
-
|
46 |
-
demo = gr.Interface(fn=air_quality, title="Air quality predictor",
|
47 |
-
description="Next week's AQI prediction for Paris", inputs="text", outputs="text")
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
if __name__ == "__main__":
|
52 |
-
demo.launch()
|
53 |
-
import gradio as gr
|
54 |
-
import hopsworks
|
55 |
-
import joblib
|
56 |
-
import pandas as pd
|
57 |
-
import numpy as np
|
58 |
-
import json
|
59 |
-
import time
|
60 |
-
from datetime import timedelta, datetime
|
61 |
-
|
62 |
-
|
63 |
-
from functions import *
|
64 |
-
|
65 |
-
|
66 |
-
project = hopsworks.login()
|
67 |
-
fs = project.get_feature_store()
|
68 |
-
|
69 |
-
|
70 |
-
def air_quality(city):
|
71 |
-
weather_df = pd.DataFrame()
|
72 |
-
for i in range(8):
|
73 |
-
weather_data = get_weather_df([get_weather_data((datetime.now() + timedelta(days=i)).strftime("%Y-%m-%d"))])
|
74 |
-
weather_df = weather_df.append(weather_data)
|
75 |
-
|
76 |
-
weather_df = weather_df.drop(columns=["precipprob", "uvindex", "date","city","conditions"]).fillna(0)
|
77 |
-
|
78 |
-
mr = project.get_model_registry()
|
79 |
-
model = mr.get_model("gradient_boost_model", version=1)
|
80 |
-
model_dir = model.download()
|
81 |
-
model = joblib.load(model_dir + "/model.pkl")
|
82 |
-
|
83 |
-
preds = model.predict(weather_df)
|
84 |
-
|
85 |
-
predictions = ''
|
86 |
-
for k in range(7):
|
87 |
-
predictions += "Predicted AQI on " + (datetime.now() + timedelta(days=k)).strftime('%Y-%m-%d') + ": " + str(int(preds[k]))+"\n"
|
88 |
-
|
89 |
-
print(predictions)
|
90 |
-
return predictions
|
91 |
-
|
92 |
-
|
93 |
-
demo = gr.Interface(fn=air_quality, title="Air quality predictor",
|
94 |
-
description="Next week's AQI prediction for Paris", inputs="text", outputs="text")
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
if __name__ == "__main__":
|
99 |
-
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|