#!/usr/bin/env python # coding: utf-8 # In[1]: import pickle import gradio as gr # In[3]: def pred(Age,Parch,Sex_female,Sex_male,Embarked_C,Embarked_Q,Embarked_S): with open("survived.pkl", "rb") as f: clf = pickle.load(f) preds = clf.predict([[Age,Parch,Sex_female,Sex_male,Embarked_C,Embarked_Q,Embarked_S]]) if preds == 1: return "He\She Survived" return "He\she Not survived" #Create the input component for Gradio since we are expecting 4 inputs Age = gr.Number(label = "Enter the Age of the Individual") Parch = gr.Dropdown([0,1,2,3,4,5,6],label= "parch") Sex_female = gr.Radio([0,1],label = "Female") Sex_male = gr.Radio([0,1],label = "male") Embarked_C = gr.Radio([0,1],label = "Embarked_C") Embarked_Q = gr.Radio([0,1],label = "Embarked_Q") Embarked_S = gr.Radio([0,1],label = "Embarked_S") # We create the output output = gr.Textbox(label="Survival status") app = gr.Interface(fn = pred, inputs=[Age,Parch,Sex_female,Sex_male,Embarked_C,Embarked_Q,Embarked_S], outputs=output,title="Titanic Survival",) app.launch(share=True) # In[ ]: