Spaces:
Runtime error
Runtime error
gg yet again
Browse files
app.py
CHANGED
@@ -6,92 +6,70 @@ import requests
|
|
6 |
import hopsworks
|
7 |
import joblib
|
8 |
|
9 |
-
project = hopsworks.login(api_key_value="rA4UUi0EGe9o2Lpo.xoqva15Ia7l8Fz7PBFrFTV4WjSG8B1aQofJlVp3oV3Xp0iHyFTzw5ybC4OapypyU")
|
10 |
-
fs = project.get_feature_store()
|
11 |
-
|
12 |
-
|
13 |
-
mr = project.get_model_registry()
|
14 |
-
model = mr.get_model("titanic_modal", version=1)
|
15 |
-
model_dir = model.download()
|
16 |
-
model = joblib.load(model_dir + "/titanic_model.pkl")
|
17 |
-
|
18 |
-
def titanic(pclass, sex, age, sibsp, parch, fare, embarked):
|
19 |
-
input_list = []
|
20 |
-
input_list.append(pclass)
|
21 |
-
input_list.append(sex)
|
22 |
-
input_list.append(age)
|
23 |
-
input_list.append(sibsp)
|
24 |
-
input_list.append(parch)
|
25 |
-
input_list.append(fare)
|
26 |
-
input_list.append(embarked)
|
27 |
-
# 'res' is a list of predictions returned as the label.
|
28 |
-
res = model.predict(np.asarray(input_list).reshape(1, -1))
|
29 |
-
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
30 |
-
# the first element.
|
31 |
-
return res[0]
|
32 |
|
|
|
|
|
|
|
|
|
33 |
|
34 |
-
# def
|
35 |
# input_list = []
|
36 |
-
# input_list.append(
|
37 |
-
# input_list.append(
|
38 |
-
# input_list.append(
|
39 |
-
# input_list.append(
|
|
|
|
|
|
|
40 |
# # 'res' is a list of predictions returned as the label.
|
41 |
-
# res = model.predict(np.asarray(input_list).reshape(1, -1))
|
42 |
-
# # We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
43 |
# # the first element.
|
44 |
-
#
|
45 |
-
|
46 |
-
# return img
|
47 |
|
48 |
-
demo = gr.Interface(
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
|
64 |
-
demo.launch()
|
65 |
|
66 |
# monitoring part of the code
|
67 |
-
|
68 |
-
|
69 |
-
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
-
# project = hopsworks.login(api_key_value="rA4UUi0EGe9o2Lpo.xoqva15Ia7l8Fz7PBFrFTV4WjSG8B1aQofJlVp3oV3Xp0iHyFTzw5ybC4OapypyU")
|
72 |
-
# fs = project.get_feature_store()
|
73 |
-
# #h
|
74 |
-
# dataset_api = project.get_dataset_api()
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
# dataset_api.download("Resources/images/df_recent.png")
|
79 |
-
# dataset_api.download("Resources/images/confusion_matrix.png")
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
# with gr.Row():
|
90 |
-
# with gr.Column():
|
91 |
-
# gr.Label("Recent Prediction History")
|
92 |
-
# input_img = gr.Image("df_recent.png", elem_id="recent-predictions")
|
93 |
-
# with gr.Column():
|
94 |
-
# gr.Label("Confusion Maxtrix with Historical Prediction Performance")
|
95 |
-
# input_img = gr.Image("confusion_matrix.png", elem_id="confusion-matrix")
|
96 |
|
97 |
-
|
|
|
6 |
import hopsworks
|
7 |
import joblib
|
8 |
|
9 |
+
# project = hopsworks.login(api_key_value="rA4UUi0EGe9o2Lpo.xoqva15Ia7l8Fz7PBFrFTV4WjSG8B1aQofJlVp3oV3Xp0iHyFTzw5ybC4OapypyU")
|
10 |
+
# fs = project.get_feature_store()
|
11 |
+
# #q
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
# mr = project.get_model_registry()
|
14 |
+
# model = mr.get_model("titanic_modal", version=1)
|
15 |
+
# model_dir = model.download()
|
16 |
+
# model = joblib.load(model_dir + "/titanic_model.pkl")
|
17 |
|
18 |
+
# def titanic(pclass, sex, age, sibsp, parch, fare, embarked):
|
19 |
# input_list = []
|
20 |
+
# input_list.append(pclass)
|
21 |
+
# input_list.append(sex)
|
22 |
+
# input_list.append(age)
|
23 |
+
# input_list.append(sibsp)
|
24 |
+
# input_list.append(parch)
|
25 |
+
# input_list.append(fare)
|
26 |
+
# input_list.append(embarked)
|
27 |
# # 'res' is a list of predictions returned as the label.
|
28 |
+
# res = model.predict(np.asarray(input_list).reshape(1, -1))
|
29 |
+
# # We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
30 |
# # the first element.
|
31 |
+
# return res[0]
|
32 |
+
|
|
|
33 |
|
34 |
+
# demo = gr.Interface(
|
35 |
+
# fn=titanic,
|
36 |
+
# title="Titanic Predictive Analytics",
|
37 |
+
# description="Experiment to predict if a passenger survived the Titanic disaster",
|
38 |
+
# allow_flagging="never",
|
39 |
+
# inputs=[
|
40 |
+
# gr.inputs.Number(default=1.0, label="PClass"),
|
41 |
+
# gr.inputs.Number(default=1.0, label="Sex: Female = 0, Male = 1"),
|
42 |
+
# gr.inputs.Number(default=1.0, label="Age"),
|
43 |
+
# gr.inputs.Number(default=1.0, label="SibSp"),
|
44 |
+
# gr.inputs.Number(default=1.0, label="Parch"),
|
45 |
+
# gr.inputs.Number(default=1.0, label="Fare"),
|
46 |
+
# gr.inputs.Number(default=1.0, label="Embarked: S = 0, C = 1, Q = 2"),
|
47 |
+
# ],
|
48 |
+
# outputs=gr.Textbox())
|
49 |
|
50 |
+
# demo.launch()
|
51 |
|
52 |
# monitoring part of the code
|
53 |
+
import gradio as gr
|
54 |
+
from PIL import Image
|
55 |
+
import hopsworks
|
56 |
+
|
57 |
+
project = hopsworks.login(api_key_value="rA4UUi0EGe9o2Lpo.xoqva15Ia7l8Fz7PBFrFTV4WjSG8B1aQofJlVp3oV3Xp0iHyFTzw5ybC4OapypyU")
|
58 |
+
fs = project.get_feature_store()
|
59 |
+
#h
|
60 |
+
dataset_api = project.get_dataset_api()
|
61 |
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
dataset_api.download("Resources/images/df_recent.png")
|
64 |
+
dataset_api.download("Resources/images/confusion_matrix.png")
|
|
|
|
|
65 |
|
66 |
+
with gr.Blocks() as demo:
|
67 |
+
with gr.Row():
|
68 |
+
with gr.Column():
|
69 |
+
gr.Label("Recent Prediction History")
|
70 |
+
input_img = gr.Image("df_recent.png", elem_id="recent-predictions")
|
71 |
+
with gr.Column():
|
72 |
+
gr.Label("Confusion Maxtrix with Historical Prediction Performance")
|
73 |
+
input_img = gr.Image("confusion_matrix.png", elem_id="confusion-matrix")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
+
demo.launch()
|