Upload Logisti-gradio.py
Browse files- Logisti-gradio.py +43 -0
Logisti-gradio.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
# coding: utf-8
|
3 |
+
|
4 |
+
# In[1]:
|
5 |
+
|
6 |
+
|
7 |
+
import pickle
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
|
11 |
+
# In[3]:
|
12 |
+
|
13 |
+
|
14 |
+
def pred(Age,Parch,Sex_female,Sex_male,Embarked_C,Embarked_Q,Embarked_S):
|
15 |
+
with open("survived.pkl", "rb") as f:
|
16 |
+
clf = pickle.load(f)
|
17 |
+
preds = clf.predict([[Age,Parch,Sex_female,Sex_male,Embarked_C,Embarked_Q,Embarked_S]])
|
18 |
+
if preds == 1:
|
19 |
+
return "He\She Survived"
|
20 |
+
return "He\she Not survived"
|
21 |
+
|
22 |
+
#Create the input component for Gradio since we are expecting 4 inputs
|
23 |
+
|
24 |
+
Age = gr.Number(label = "Enter the Age of the Individual")
|
25 |
+
Parch = gr.Dropdown([0,1,2,3,4,5,6],label= "parch")
|
26 |
+
Sex_female = gr.Radio([0,1],label = "Female")
|
27 |
+
Sex_male = gr.Radio([0,1],label = "male")
|
28 |
+
Embarked_C = gr.Radio([0,1],label = "Embarked_C")
|
29 |
+
Embarked_Q = gr.Radio([0,1],label = "Embarked_Q")
|
30 |
+
Embarked_S = gr.Radio([0,1],label = "Embarked_S")
|
31 |
+
# We create the output
|
32 |
+
output = gr.Textbox(label="Survival status")
|
33 |
+
|
34 |
+
|
35 |
+
app = gr.Interface(fn = pred, inputs=[Age,Parch,Sex_female,Sex_male,Embarked_C,Embarked_Q,Embarked_S], outputs=output,title="Titanic Survival",)
|
36 |
+
app.launch(share=True)
|
37 |
+
|
38 |
+
|
39 |
+
# In[ ]:
|
40 |
+
|
41 |
+
|
42 |
+
|
43 |
+
|