carlpersson commited on
Commit
6ce1574
·
1 Parent(s): 9dd626b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import hopsworks
3
+
4
+ project = hopsworks.login()
5
+ fs = project.get_feature_store()
6
+
7
+ dataset_api = project.get_dataset_api()
8
+ wine_pred_fg = fs.get_feature_group(name="wine_predictions", version=1)
9
+ df = wine_pred_fg.read()
10
+ print(df)
11
+ latest_pred = df['prediction'].iloc[-1]
12
+ latest_label = df['label'].iloc[-1]
13
+ latest_pred = {'High Quality': float(latest_pred[2]),
14
+ 'Good Quality': float(latest_pred[1]),
15
+ 'Low Quality': float(latest_pred[0])}
16
+ latest_label = 'Low Quality' if latest_label == 0 else 'Good Quality' if latest_label == 1 else 'High Quality'
17
+
18
+ dataset_api.download("Resources/images/df_recent.png", overwrite=True)
19
+ dataset_api.download("Resources/images/confusion_matrix.png", overwrite=True)
20
+
21
+ with gr.Blocks() as demo:
22
+ with gr.Row():
23
+ with gr.Column():
24
+ gr.Label("Today's Predicted Wine Quality")
25
+ gr.Label(latest_pred, num_top_classes=3, )
26
+ with gr.Column():
27
+ gr.Label("Today's Actual Wine Quality ")
28
+ gr.Label(latest_label)
29
+ with gr.Row():
30
+ with gr.Column():
31
+ gr.Label("Recent Prediction History")
32
+ input_img = gr.Image("df_recent.png", elem_id="recent-predictions")
33
+ with gr.Column():
34
+ gr.Label("Confusion Maxtrix with Historical Prediction Performance")
35
+ input_img = gr.Image("confusion_matrix.png", elem_id="confusion-matrix")
36
+
37
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ hopsworks