Spaces:
Runtime error
Runtime error
humbertojunior
commited on
Commit
•
d0e1cce
1
Parent(s):
db5370c
Create file app.py in gradio
Browse files
app.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import joblib as jb
|
3 |
+
|
4 |
+
def predict(sex, age, pclass):
|
5 |
+
model = jb.load('model.pkl')
|
6 |
+
pclass = int(pclass)
|
7 |
+
p = model.predict_proba([[sex, age, pclass]])[0]
|
8 |
+
|
9 |
+
return {"Did not survive": p[0], "Survived": p[1]}
|
10 |
+
|
11 |
+
demo = gr.Interface(fn=predict,
|
12 |
+
inputs=[gr.Dropdown(choices=["male", "female"], type="index"),
|
13 |
+
"number",
|
14 |
+
gr.Dropdown(choices=["1", "2", "3"], type="value")
|
15 |
+
],
|
16 |
+
outputs="label")
|
17 |
+
demo.launch()
|