Yasaman commited on
Commit
41ffca6
·
1 Parent(s): c5dbfc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -28
app.py CHANGED
@@ -20,43 +20,25 @@ feature_view = fs.get_feature_view(
20
  )
21
 
22
 
23
- def air_quality(city):
24
- air_quality_df = pd.DataFrame()
25
- weather_df = pd.DataFrame()
26
- for i in range(8):
27
- weather_data = get_weather_df([get_weather_data((datetime.now() + timedelta(days=i)).strftime("%Y-%m-%d"))])
28
- weather_df = weather_df.append(weather_data)
29
 
30
- quality_data= get_air_quality_df([get_air_quality_data(city)])
31
- air_quality_df=air_quality_df.append(quality_data)
32
- print(air_quality_df)
33
- print(weather_df)
34
-
35
- weather_df = weather_df.drop(columns=["feelslikemin", "feelslikemax","precipprob", "snow", "snowdepth", "uvindex", "date","city","conditions"]).fillna(0)
36
 
37
- start_date = datetime.now() - timedelta(days=1)
38
- start_time = int(start_date.timestamp()) * 1000
39
- X = feature_view.get_batch_data(start_time=start_time)
40
 
41
- X = X.drop(columns=["date"]).fillna(0)
42
 
43
- mr = project.get_model_registry()
44
- model = mr.get_model("gradient_boost_paris_model", version=1)
45
- model_dir = model.download()
46
- model = joblib.load(model_dir + "/model.pkl")
47
 
48
- preds = model.predict(X)
49
 
50
- """predictions = ''
51
- for k in range(7):
52
- predictions += "Predicted AQI on " + (datetime.now() + timedelta(days=k)).strftime('%Y-%m-%d') + ": " + str(int(preds[k]))+"\n"
53
-
54
- print(predictions)"""
55
- return preds
56
 
57
 
58
  demo = gr.Interface(fn=air_quality, title="Air quality predictor",
59
- description="Input a value to get next weeks AQI prediction for Malmo", inputs="text", outputs="text")
60
 
61
 
62
 
 
20
  )
21
 
22
 
 
 
 
 
 
 
23
 
 
 
 
 
 
 
24
 
25
+ start_date = datetime.now() - timedelta(days=1)
26
+ start_time = int(start_date.timestamp()) * 1000
27
+ X = feature_view.get_batch_data(start_time=start_time)
28
 
29
+ X = X.drop(columns=["date"]).fillna(0)
30
 
31
+ mr = project.get_model_registry()
32
+ model = mr.get_model("gradient_boost_paris_model", version=1)
33
+ model_dir = model.download()
34
+ model = joblib.load(model_dir + "/model.pkl")
35
 
36
+ preds = model.predict(X)
37
 
 
 
 
 
 
 
38
 
39
 
40
  demo = gr.Interface(fn=air_quality, title="Air quality predictor",
41
+ description="Input a value to get next weeks AQI prediction for Paris", inputs="text", outputs="text")
42
 
43
 
44