Qinglinz commited on
Commit
3d24d8f
1 Parent(s): 47882b6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -46,17 +46,17 @@ def titanic(pclass, sex, age, fare, embarked, familysize, appellation, cabin):
46
 
47
  # Appellation
48
  if appellation == "master":
49
- input_list.append(1).append(0).append(0).append(0).append(0).append(0)
50
  elif appellation == "miss":
51
- input_list.append(0).append(1).append(0).append(0).append(0).append(0)
52
  elif appellation == "mr":
53
- input_list.append(0).append(0).append(1).append(0).append(0).append(0)
54
  elif appellation == "mrs":
55
- input_list.append(0).append(0).append(0).append(1).append(0).append(0)
56
  elif appellation == "officer":
57
- input_list.append(0).append(0).append(0).append(0).append(1).append(0)
58
  elif appellation == "royalty":
59
- input_list.append(0).append(0).append(0).append(0).append(0).append(1)
60
 
61
  # Cabin
62
  if cabin == "A":
@@ -82,7 +82,6 @@ def titanic(pclass, sex, age, fare, embarked, familysize, appellation, cabin):
82
  # 'res' is a list of predictions returned as the label.
83
  res = model.predict(np.asarray(input_list).reshape(1, -1))
84
  res = res.astype(int)
85
- print(res)
86
  # We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
87
  # the first element.
88
  titanic_url = "https://github.com/Qinglin2000/ID2223/blob/main/" + str(res[0]) + ".png?raw=true"
@@ -92,7 +91,7 @@ def titanic(pclass, sex, age, fare, embarked, familysize, appellation, cabin):
92
 
93
  demo = gr.Interface(
94
  fn=titanic,
95
- title="Titatnic Predictive Analytics",
96
  description="Experiment with titanic dataset values.",
97
  allow_flagging="never",
98
  inputs=[
@@ -106,5 +105,4 @@ demo = gr.Interface(
106
  gr.Dropdown(choices=["A", "B", "C", "D", "E", "F", "G", "T", "U"], label="Cabin", value="A"),
107
  ],
108
  outputs=gr.Image(type="pil"))
109
-
110
  demo.launch()
 
46
 
47
  # Appellation
48
  if appellation == "master":
49
+ input_list.append(1,0,0,0,0,0)
50
  elif appellation == "miss":
51
+ input_list.append(0,1,0,0,0,0)
52
  elif appellation == "mr":
53
+ input_list.append(0,0,1,0,0,0)
54
  elif appellation == "mrs":
55
+ input_list.append(0,0,0,1,0,0)
56
  elif appellation == "officer":
57
+ input_list.append(0,0,0,0,1,0)
58
  elif appellation == "royalty":
59
+ input_list.append(0,0,0,0,0,1)
60
 
61
  # Cabin
62
  if cabin == "A":
 
82
  # 'res' is a list of predictions returned as the label.
83
  res = model.predict(np.asarray(input_list).reshape(1, -1))
84
  res = res.astype(int)
 
85
  # We add '[0]' to the result of the transformed 'res', because 'res' is a list, and we only want
86
  # the first element.
87
  titanic_url = "https://github.com/Qinglin2000/ID2223/blob/main/" + str(res[0]) + ".png?raw=true"
 
91
 
92
  demo = gr.Interface(
93
  fn=titanic,
94
+ title="Titanic Predictive Analytics",
95
  description="Experiment with titanic dataset values.",
96
  allow_flagging="never",
97
  inputs=[
 
105
  gr.Dropdown(choices=["A", "B", "C", "D", "E", "F", "G", "T", "U"], label="Cabin", value="A"),
106
  ],
107
  outputs=gr.Image(type="pil"))
 
108
  demo.launch()