Upload 2 files
Browse files- app.py +1 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1 @@
|
|
|
|
0 |
input_list = []
|
1 |
bins = [-np.infty, 20, 25, 29, 30, 40, np.infty]
|
2 |
input_list.append(int(np.digitize([age], bins)[0]))
|
3 |
input_list.append(int(sex))
|
4 |
input_list.append(int(pclass + 1))
|
5 |
input_list.append(fare)
|
6 |
# 'res' is a list of predictions returned as the label.
|
7 |
res = model.predict(np.asarray(input_list).reshape(1, -1))
|
8 |
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
9 |
# the first element.
|
10 |
# print('The result we get :: ', str(res[0]))
|
11 |
passenger_survival_url = "https://raw.githubusercontent.com/abdullabdull/id2223-images/main/" + str(res[0]) + ".png"
|
12 |
img = Image.open(requests.get(passenger_survival_url, stream=True).raw)
|
13 |
return img
|
14 |
fn=titanic,
|
15 |
title="Titanic Survival Predictive Analytics",
|
16 |
description="Experiment with different passenger features to predict if they survived or not.",
|
17 |
allow_flagging="never",
|
18 |
inputs=[
|
19 |
gr.inputs.Dropdown(choices=["Class 1", "Class 2", "Class 3"], type="index", label="Pclass"),
|
20 |
gr.inputs.Dropdown(choices=["Male", "Female"], type="index", label="Sex"),
|
21 |
gr.inputs.Number(default=1, label="Age"),
|
22 |
gr.inputs.Slider(minimum=0, maximum=550, default=50, label="Fare"),
|
23 |
],
|
24 |
outputs=gr.Image(type="pil"))
|
|
|
1 |
+
import gradio as gr
|
2 |
input_list = []
|
3 |
bins = [-np.infty, 20, 25, 29, 30, 40, np.infty]
|
4 |
input_list.append(int(np.digitize([age], bins)[0]))
|
5 |
input_list.append(int(sex))
|
6 |
input_list.append(int(pclass + 1))
|
7 |
input_list.append(fare)
|
8 |
# 'res' is a list of predictions returned as the label.
|
9 |
res = model.predict(np.asarray(input_list).reshape(1, -1))
|
10 |
# We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
|
11 |
# the first element.
|
12 |
# print('The result we get :: ', str(res[0]))
|
13 |
passenger_survival_url = "https://raw.githubusercontent.com/abdullabdull/id2223-images/main/" + str(res[0]) + ".png"
|
14 |
img = Image.open(requests.get(passenger_survival_url, stream=True).raw)
|
15 |
return img
|
16 |
fn=titanic,
|
17 |
title="Titanic Survival Predictive Analytics",
|
18 |
description="Experiment with different passenger features to predict if they survived or not.",
|
19 |
allow_flagging="never",
|
20 |
inputs=[
|
21 |
gr.inputs.Dropdown(choices=["Class 1", "Class 2", "Class 3"], type="index", label="Pclass"),
|
22 |
gr.inputs.Dropdown(choices=["Male", "Female"], type="index", label="Sex"),
|
23 |
gr.inputs.Number(default=1, label="Age"),
|
24 |
gr.inputs.Slider(minimum=0, maximum=550, default=50, label="Fare"),
|
25 |
],
|
26 |
outputs=gr.Image(type="pil"))
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
hopsworks
|
2 |
+
joblib
|
3 |
+
scikit-learn
|