rscolati commited on
Commit
3841ae0
1 Parent(s): 2888ff8

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +5 -4
  2. app.py +36 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
  title: Electricity Monitoring
3
- emoji: 🌖
4
- colorFrom: yellow
5
- colorTo: pink
6
  sdk: gradio
7
- sdk_version: 3.16.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
  title: Electricity Monitoring
3
+ emoji: 💻
4
+ colorFrom: purple
5
+ colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 3.5
8
  app_file: app.py
9
  pinned: false
10
+ license: apache-2.0
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ with gr.Row():
21
+ with gr.Column():
22
+ gr.Label("Today's predicted NY electricity demand")
23
+ gr.Label("{:.0f}MWh".format(latest_prediction['prediction']))
24
+ with gr.Column():
25
+ gr.Label("Today's actual demand")
26
+ gr.Label("{}MWh".format(latest_prediction['actual']))
27
+ with gr.Row():
28
+ with gr.Column():
29
+ gr.Label("Recent Prediction History")
30
+ input_img = gr.Image("df_ny_elec_recent.png", elem_id="recent-predictions")
31
+ with gr.Column():
32
+ gr.Label("MAE for historical predictions")
33
+ gr.Label("{:.0f}MWh".format(mean_error))
34
+
35
+
36
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ hopsworks
2
+ scikit-learn