Spaces:
Runtime error
Runtime error
Campfireman
commited on
Commit
·
44efe75
1
Parent(s):
f117490
Update app.py
Browse files
app.py
CHANGED
@@ -4,22 +4,44 @@ import hopsworks
|
|
4 |
|
5 |
project = hopsworks.login()
|
6 |
fs = project.get_feature_store()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
-
dataset_api = project.get_dataset_api()
|
9 |
|
10 |
-
dataset_api.
|
11 |
-
dataset_api.download("Resources/images/actual_iris.png")
|
12 |
dataset_api.download("Resources/images/df_recent.png")
|
13 |
dataset_api.download("Resources/images/confusion_matrix.png")
|
14 |
|
15 |
with gr.Blocks() as demo:
|
|
|
16 |
with gr.Row():
|
17 |
with gr.Column():
|
18 |
-
gr.Label("Today's Predicted
|
19 |
-
|
20 |
with gr.Column():
|
21 |
-
gr.Label("Today's Actual
|
22 |
-
|
23 |
with gr.Row():
|
24 |
with gr.Column():
|
25 |
gr.Label("Recent Prediction History")
|
|
|
4 |
|
5 |
project = hopsworks.login()
|
6 |
fs = project.get_feature_store()
|
7 |
+
mr = project.get_model_registry()
|
8 |
+
model = mr.get_model("titanic_survival_modal", version=1)
|
9 |
+
model_dir = model.download()
|
10 |
+
model = joblib.load(model_dir + "/titanic_model.pkl")
|
11 |
+
|
12 |
+
def tb_titanic(pclass,sex,age,sibsp,parch,embarked,fare_per_customer,cabin):
|
13 |
+
input_list = []
|
14 |
+
input_list.append(pclass)
|
15 |
+
input_list.append(sex)
|
16 |
+
input_list.append(age)
|
17 |
+
input_list.append(sibsp)
|
18 |
+
input_list.append(parch)
|
19 |
+
input_list.append(embarked)
|
20 |
+
input_list.append(fare_per_customer)
|
21 |
+
input_list.append(cabin)
|
22 |
+
# 'res' is a list of predictions returned as the label.
|
23 |
+
#global res
|
24 |
+
res = model.predict(np.asarray(input_list).reshape(1, 8))
|
25 |
+
if res[0]=="S":
|
26 |
+
return ("survived")
|
27 |
+
else:
|
28 |
+
return("deceased")
|
29 |
+
|
30 |
|
|
|
31 |
|
32 |
+
dataset_api = project.get_dataset_api()
|
|
|
33 |
dataset_api.download("Resources/images/df_recent.png")
|
34 |
dataset_api.download("Resources/images/confusion_matrix.png")
|
35 |
|
36 |
with gr.Blocks() as demo:
|
37 |
+
fn=tb_titanic,
|
38 |
with gr.Row():
|
39 |
with gr.Column():
|
40 |
+
gr.Label("Today's Predicted survive")
|
41 |
+
input=gr.Textbox()
|
42 |
with gr.Column():
|
43 |
+
gr.Label("Today's Actual survive")
|
44 |
+
input=gr.Textbox()
|
45 |
with gr.Row():
|
46 |
with gr.Column():
|
47 |
gr.Label("Recent Prediction History")
|