rscolati commited on
Commit
ce4727f
1 Parent(s): 35f8d8f

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +5 -28
  2. requirements.txt +1 -2
app.py CHANGED
@@ -1,44 +1,21 @@
1
  import gradio as gr
2
  import hopsworks
3
- from sklearn.metrics import mean_absolute_error
4
 
5
  project = hopsworks.login()
6
- fs = project.get_feature_store()
7
-
8
- monitor_fg = fs.get_feature_group(name="ny_elec_predictions", version=1)
9
- history_df = monitor_fg.read()
10
- latest_prediction = history_df.iloc[-1]
11
-
12
- y_pred = history_df['prediction']
13
- y_test = history_df['actual']
14
- mean_error = mean_absolute_error(y_test, y_pred)
15
 
16
  dataset_api = project.get_dataset_api()
17
  dataset_api.download("Resources/images/df_ny_elec_recent.png", overwrite=True)
 
18
 
19
  with gr.Blocks() as demo:
20
- gr.Label("Today's prediction")
21
- with gr.Row():
22
- with gr.Column():
23
- gr.Textbox(value="{}".format(latest_prediction['prediction_date']),
24
- label="Prediction date")
25
- with gr.Column():
26
- gr.Textbox(value="{:.0f}MWh".format(latest_prediction['prediction']),
27
- label="Predicted NY electricity demand")
28
  with gr.Row():
29
  with gr.Column():
30
- gr.Textbox(value="{}MWh".format(latest_prediction['actual']),
31
- label="Actual demand")
32
- with gr.Column():
33
- gr.Textbox(value="{}MWh".format(latest_prediction['forecast_eia']),
34
- label="EIA forecast")
35
- gr.Label("Recent Prediction History")
36
- with gr.Row():
37
  with gr.Column():
 
38
  input_img = gr.Image("df_ny_elec_recent.png", elem_id="recent-predictions")
39
- with gr.Column():
40
- gr.Textbox(label="MAE for historical predictions",
41
- value="{:.0f}MWh".format(mean_error))
42
 
43
 
44
  demo.launch()
 
1
  import gradio as gr
2
  import hopsworks
 
3
 
4
  project = hopsworks.login()
 
 
 
 
 
 
 
 
 
5
 
6
  dataset_api = project.get_dataset_api()
7
  dataset_api.download("Resources/images/df_ny_elec_recent.png", overwrite=True)
8
+ dataset_api.download("Resources/images/df_ny_elec_prediction.png", overwrite=True)
9
 
10
  with gr.Blocks() as demo:
 
 
 
 
 
 
 
 
11
  with gr.Row():
12
  with gr.Column():
13
+ gr.Label("Today's prediction")
14
+ input_img = gr.Image("df_ny_elec_prediction.png", elem_id="latest-prediction")
 
 
 
 
 
15
  with gr.Column():
16
+ gr.Label("Recent Prediction History")
17
  input_img = gr.Image("df_ny_elec_recent.png", elem_id="recent-predictions")
18
+ # TODO: MAE plot
 
 
19
 
20
 
21
  demo.launch()
requirements.txt CHANGED
@@ -1,2 +1 @@
1
- hopsworks
2
- scikit-learn
 
1
+ hopsworks