Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,68 +1,36 @@
|
|
1 |
import gradio as gr
|
2 |
import hopsworks
|
3 |
-
import joblib
|
4 |
-
import pandas as pd
|
5 |
|
6 |
-
|
7 |
-
'volatile_acidity',
|
8 |
-
'citric_acid',
|
9 |
-
'residual_sugar',
|
10 |
-
'chlorides',
|
11 |
-
'free_sulfur_dioxide',
|
12 |
-
'total_sulfur_dioxide',
|
13 |
-
'density',
|
14 |
-
'pH',
|
15 |
-
'sulphates',
|
16 |
-
'alcohol',
|
17 |
-
'is_white']
|
18 |
-
labels = ["Low", "Medium", "High"]
|
19 |
|
20 |
project = hopsworks.login()
|
21 |
fs = project.get_feature_store()
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
allow_flagging="never",
|
52 |
-
inputs=[
|
53 |
-
gr.components.Number(label='fixed acidity'),
|
54 |
-
gr.components.Number(label='volatile acidity'),
|
55 |
-
gr.components.Number(label='citric acid'),
|
56 |
-
gr.components.Number(label='residual sugar'),
|
57 |
-
gr.components.Number(label='chlorides'),
|
58 |
-
gr.components.Number(label='free sulfur dioxide'),
|
59 |
-
gr.components.Number(label='total sulfur dioxide'),
|
60 |
-
gr.components.Number(label='density'),
|
61 |
-
gr.components.Number(label='pH'),
|
62 |
-
gr.components.Number(label='sulphates'),
|
63 |
-
gr.components.Number(label='alcohol'),
|
64 |
-
gr.components.Checkbox(label='is white'),
|
65 |
-
],
|
66 |
-
outputs=gr.Text())
|
67 |
-
|
68 |
-
demo.launch(debug=True)
|
|
|
1 |
import gradio as gr
|
2 |
import hopsworks
|
|
|
|
|
3 |
|
4 |
+
labels = ['Low', 'Medium', 'High']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
project = hopsworks.login()
|
7 |
fs = project.get_feature_store()
|
8 |
|
9 |
+
dataset_api = project.get_dataset_api()
|
10 |
+
dataset_api.download("Resources/images/wine_df_recent.png")
|
11 |
+
dataset_api.download("Resources/images/wine_confusion_matrix.png")
|
12 |
+
|
13 |
+
monitor_fg = fs.get_or_create_feature_group(name="wine_predictions", version=1, primary_key=["datetime"],
|
14 |
+
description="Wine quality Prediction/Outcome Monitoring")
|
15 |
+
|
16 |
+
history_df = monitor_fg.read()
|
17 |
+
last_prediction = history_df.tail()
|
18 |
+
last_prediction = last_prediction[0] if len(last_prediction) > 0 else None
|
19 |
+
|
20 |
+
with gr.Blocks() as demo:
|
21 |
+
with gr.Row():
|
22 |
+
with gr.Column():
|
23 |
+
gr.Label("Today's Predicted")
|
24 |
+
gr.Label(f"{labels[last_prediction['prediction']] + ' quality' if last_prediction is not None else 'No predictions yet'}")
|
25 |
+
with gr.Column():
|
26 |
+
gr.Label("Today's Actual quality")
|
27 |
+
gr.Label(f"{labels[last_prediction['label']] + ' quality' if last_prediction is not None else 'No predictions yet'}")
|
28 |
+
with gr.Row():
|
29 |
+
with gr.Column():
|
30 |
+
gr.Label("Recent Prediction History")
|
31 |
+
gr.Image("wine_df_recent.png", elem_id="recent-predictions")
|
32 |
+
with gr.Column():
|
33 |
+
gr.Label("Confusion Maxtrix with Historical Prediction Performance")
|
34 |
+
gr.Image("wine_confusion_matrix.png", elem_id="confusion-matrix")
|
35 |
+
|
36 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|