soheiltp commited on
Commit
15c6132
1 Parent(s): 69a77d7

Upload 4 files

Browse files
Files changed (4) hide show
  1. app.py +33 -0
  2. requirements.txt +59 -0
  3. utils.py +19 -0
  4. xgbpipe.joblib +3 -0
app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from utils import PrepProcesor, columns
3
+
4
+ import numpy as np
5
+ import pandas as pd
6
+ import joblib
7
+
8
+ model = joblib.load('xgbpipe.joblib')
9
+ st.title('Will you survive if you were among Titanic passengers or not :ship:')
10
+ # PassengerId,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked
11
+ passengerid = st.text_input("Input Passenger ID", '8585')
12
+ pclass = st.selectbox("Choose class", [1,2,3])
13
+ name = st.text_input("Input Passenger Name", 'Soheil Tehranipour')
14
+ sex = st.select_slider("Choose sex", ['male','female'])
15
+ age = st.slider("Choose age",0,100)
16
+ sibsp = st.slider("Choose siblings",0,10)
17
+ parch = st.slider("Choose parch",0,10)
18
+ ticket = st.text_input("Input Ticket Number", "8585")
19
+ fare = st.number_input("Input Fare Price", 0,1000)
20
+ cabin = st.text_input("Input Cabin", "C52")
21
+ embarked = st.select_slider("Did they Embark?", ['S','C','Q'])
22
+
23
+ def predict():
24
+ row = np.array([passengerid,pclass,name,sex,age,sibsp,parch,ticket,fare,cabin,embarked])
25
+ X = pd.DataFrame([row], columns = columns)
26
+ prediction = model.predict(X)
27
+ if prediction[0] == 1:
28
+ st.success('Passenger Survived :thumbsup:')
29
+ else:
30
+ st.error('Passenger did not Survive :thumbsdown:')
31
+
32
+ trigger = st.button('Predict', on_click=predict)
33
+
requirements.txt ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==4.2.0
2
+ attrs==22.1.0
3
+ blinker==1.5
4
+ cachetools==5.2.0
5
+ charset-normalizer==2.1.1
6
+ click==8.1.3
7
+ colorama==0.4.6
8
+ commonmark==0.9.1
9
+ contourpy==1.0.6
10
+ cycler==0.11.0
11
+ decorator==5.1.1
12
+ entrypoints==0.4
13
+ fonttools==4.38.0
14
+ gitdb==4.0.10
15
+ GitPython==3.1.29
16
+ idna==3.4
17
+ importlib-metadata==5.1.0
18
+ Jinja2==3.1.2
19
+ joblib==1.2.0
20
+ jsonschema==4.17.3
21
+ kiwisolver==1.4.4
22
+ MarkupSafe==2.1.1
23
+ matplotlib==3.6.2
24
+ numpy==1.23.5
25
+ packaging==21.3
26
+ pandas==1.5.2
27
+ Pillow==9.3.0
28
+ protobuf==3.20.3
29
+ pyarrow==10.0.1
30
+ pydeck==0.8.0
31
+ Pygments==2.13.0
32
+ Pympler==1.0.1
33
+ pyparsing==3.0.9
34
+ pyrsistent==0.19.2
35
+ python-dateutil==2.8.2
36
+ pytz==2022.6
37
+ pytz-deprecation-shim==0.1.0.post0
38
+ requests==2.28.1
39
+ rich==12.6.0
40
+ scikit-learn==1.1.3
41
+ scipy==1.9.3
42
+ seaborn==0.12.1
43
+ semver==2.13.0
44
+ six==1.16.0
45
+ smmap==5.0.0
46
+ streamlit==1.11.1
47
+ threadpoolctl==3.1.0
48
+ toml==0.10.2
49
+ toolz==0.12.0
50
+ tornado==6.2
51
+ typing_extensions==4.4.0
52
+ tzdata==2022.7
53
+ tzlocal==4.2
54
+ urllib3==1.26.13
55
+ validators==0.20.0
56
+ watchdog==2.2.0
57
+ wincertstore==0.2
58
+ xgboost==1.5.0
59
+ zipp==3.11.0
utils.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sklearn.base import BaseEstimator, TransformerMixin
2
+ from sklearn.impute import SimpleImputer
3
+ import re
4
+
5
+ class PrepProcesor(BaseEstimator, TransformerMixin):
6
+ def fit(self, X, y=None):
7
+ self.ageImputer = SimpleImputer()
8
+ self.ageImputer.fit(X[['Age']])
9
+ return self
10
+
11
+ def transform(self, X, y=None):
12
+ X['Age'] = self.ageImputer.transform(X[['Age']])
13
+ X['CabinClass'] = X['Cabin'].fillna('M').apply(lambda x: str(x).replace(" ", "")).apply(lambda x: re.sub(r'[^a-zA-Z]', '', x))
14
+ X['CabinNumber'] = X['Cabin'].fillna('M').apply(lambda x: str(x).replace(" ", "")).apply(lambda x: re.sub(r'[^0-9]', '', x)).replace('', 0)
15
+ X['Embarked'] = X['Embarked'].fillna('M')
16
+ X = X.drop(['PassengerId', 'Name', 'Ticket','Cabin'], axis=1)
17
+ return X
18
+
19
+ columns = ['PassengerId', 'Pclass', 'Name', 'Sex', 'Age', 'SibSp', 'Parch','Ticket', 'Fare', 'Cabin', 'Embarked']
xgbpipe.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8117b0f8e5f9c01468c6e2bdf6e6115f00cdaf2ad407244292a88dfdd72a9807
3
+ size 275462