File size: 1,469 Bytes
a1d4102
 
 
4942701
a1d4102
 
 
 
4942701
 
 
 
 
 
 
 
137e221
 
4942701
 
 
 
 
 
 
 
137e221
4942701
 
 
 
 
 
 
 
5d09621
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import gradio as gr
import hopsworks

labels = ['Low', 'Medium', 'High']

project = hopsworks.login()
fs = project.get_feature_store()

dataset_api = project.get_dataset_api()
dataset_api.download("Resources/images/wine_df_recent.png")
dataset_api.download("Resources/images/wine_confusion_matrix.png")

monitor_fg = fs.get_or_create_feature_group(name="wine_predictions", version=1, primary_key=["datetime"],
                                            description="Wine quality Prediction/Outcome Monitoring")

history_df = monitor_fg.read()
last_prediction = history_df.tail(1)
last_prediction = last_prediction.to_dict(orient='records')[0]

with gr.Blocks() as demo:
    with gr.Row():
        with gr.Column():
            gr.Label("Today's Predicted")
            gr.Label(f"{labels[last_prediction['prediction']] + ' quality' if last_prediction is not None else 'No predictions yet'}")
        with gr.Column():
            gr.Label("Today's Actual quality")
            gr.Label(f"{labels[int(last_prediction['label'])] + ' quality' if last_prediction is not None else 'No predictions yet'}")
    with gr.Row():
        with gr.Column():
            gr.Label("Recent Prediction History")
            gr.Image("wine_df_recent.png", elem_id="recent-predictions")
        with gr.Column():
            gr.Label("Confusion Maxtrix with Historical Prediction Performance")
            gr.Image("wine_confusion_matrix.png", elem_id="confusion-matrix")

demo.launch()