-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreamlit_app1.py
111 lines (85 loc) · 4.11 KB
/
streamlit_app1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import pickle
import streamlit as st
from numpy import array
import pandas as pd
st.set_page_config(
page_title='Will You Survive If You Were In Titanic ? :ship:',
layout='centered',
initial_sidebar_state='expanded'
)
data= pd.read_csv('Taitanic.csv')
st.sidebar.image('https://i.pinimg.com/564x/8a/5d/95/8a5d9586fbe7a3cbd0dad8c9c160e898.jpg')
st.image('https://www.financialexpress.com/wp-content/uploads/2023/06/Sub-Cover.jpg?w=580')
st.title('Will You Survive If You Were In Titanic ? :ship:')
'''
[](https://github.com/Ahmed-G-ElTaher/Will-You-Survive-If-You-Were-In-Titanic)
'''
st.markdown("<br>",unsafe_allow_html=True)
'''
[](mailto:[email protected])
[](https://www.linkedin.com/in/ahmed-el-taher/)
'''
st.markdown("<br>",unsafe_allow_html=True)
'---------------------------------------------'
st.header("Input Your Data 📑 ")
st.header("To Know If You Lucky To Survive ♻ ")
'---------------------------------------------'
model = pickle.load(open('model.pkl', 'rb'))
name = st.text_input("Input Your Name : ", 'John Smith')
Sex0 = st.selectbox("Choose Your Gender : ", ['male','female'])
if Sex0 == 'male' :
Sex = 1
elif Sex0 == 'female' :
Sex = 0
Age = st.slider("Choose Your Age : ",0,100)
SibSp = st.slider("How Many Siblings Will You Take With You ? ",0,8)
Parch = st.slider("Will You Take One Of Your Parents Or Not ? ",0,2)
Embarked = st.selectbox("Choose Your Port of Embarkation (C = Cherbourg; Q = Queenstown; S = Southampton)", ['S','C','Q'])
Fare = st.number_input("Input Fare Price You Will Pay To Book A Ticket : ", 0,520)
C=1
if Fare :
id = data[data['Fare'] >= Fare]['PassengerId'].sample(n=1).values[0]
passengerid = st.write("Your ID Passenger Is: ", id)
c = 0
if Fare <= 150 :
c = 'Third Class'
C=3
elif 150 < Fare < 350 :
c = 'Second Class'
C=2
elif Fare >= 350 :
c = 'First class'
C=1
Pclass = st.write("Your Class Is: " , c )
booking = data[data['Fare'] >= Fare]['Ticket'].sample(n=1).values[0]
ticket = st.write("Your Ticket Number Is: ", booking)
room = data[data['Fare'] >= Fare]['Cabin'].dropna().sample(n=1).values[0]
cabin = st.write("Your Cabin Is: ", room)
if Embarked == 'C' :
Embarked = 0
elif Embarked == 'S' :
Embarked = 2
else :
Embarked = 1
trigger = st.button('Predict Your Fate')
Pclass = C
columns = ['Sex','Age','Pclass','Fare','Embarked','SibSp','Parch']
if trigger :
row = array([Sex,Age,Pclass,Fare,Embarked,SibSp,Parch])
X = pd.DataFrame([row],columns=columns)
prediction = model.predict(X)
if prediction[0] == 1:
st.write('Passenger Survived :thumbsup:')
with st.expander("Your Fate",expanded=True):
st.write("Don't worry you are in survive boat. 😄 ")
st.image("https://cdn.arstechnica.net/wp-content/uploads/2023/02/jack5.jpg")
else:
st.write('Passenger did not Survive :thumbsdown:')
if Sex0 == 'male' :
with st.expander("Your Fate",expanded=True):
st.write("unfortunately, you didn't Survive. 😞 ")
st.image("https://thumbs.gfycat.com/DifficultNimbleAntbear-size_restricted.gif")
else :
with st.expander("Your Fate",expanded=True):
st.write("unfortunately, you didn't Survive. 😞 ")
st.image("https://s3.amazonaws.com/snwceomedia/ame-egl/ebb15fca-2426-412c-b7f2-dba39077efb2.sized-1000x1000.gif?w=1000")