yt_tut1 / app.py
mariofilho's picture
titanic v1
7fec8d1
raw
history blame contribute delete
544 Bytes
from secrets import choice
import gradio as gr
import joblib as jb
def predict(sex, age, pclass):
model = jb.load('model.pkl')
pclass += 1
p = model.predict_proba([[sex, age, pclass]])[0]
return {"Did not survive": p[0], "Survived": p[1]}
demo = gr.Interface(fn=predict,
inputs=[gr.Dropdown(choices=["male", "female"], type="index")
, "number",
gr.Dropdown(choices=["1", "2", "3"], type="index")],
outputs="label")
demo.launch()