AlselloDM commited on
Commit
7b7020e
1 Parent(s): 9203dae

Upload 6 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ h8dsft_P1M2_AlselloDM.ipynb filter=lfs diff=lfs merge=lfs -text
Application_Data.csv ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import joblib
4
+ from bs4 import BeautifulSoup
5
+ import numpy as np
6
+ import matplotlib.pyplot as plt
7
+ import seaborn as sns
8
+ from imblearn.pipeline import Pipeline as imbpipe
9
+
10
+
11
+
12
+ APP_ICON_URL = "credit-card.png"
13
+
14
+ # Setup web page
15
+ st.set_page_config(
16
+ page_title="CREDIT CARD APPROVAL APP",
17
+ page_icon=APP_ICON_URL,
18
+ layout="wide",
19
+ )
20
+
21
+ st.markdown("""
22
+ <style type="text/css">
23
+ blockquote {
24
+ margin: 1em 0px 1em -1px;
25
+ padding: 0px 0px 0px 1.2em;
26
+ font-size: 20px;
27
+ border-left: 5px solid rgb(230, 234, 241);
28
+ # background-color: rgb(129, 164, 182);
29
+ }
30
+ blockquote p {
31
+ font-size: 30px;
32
+ color: #FFFFFF;
33
+ }
34
+ [data-testid=stSidebar] {
35
+ background-color: rgb(129, 164, 182);
36
+ color: #FFFFFF;
37
+ }
38
+ [aria-selected="true"] {
39
+ color: #000000;
40
+ }
41
+ </style>
42
+ """, unsafe_allow_html=True)
43
+ with st.container():
44
+ col1,col2,_,_ = st.columns([1,14,1,1],gap="large")
45
+ with col1:
46
+ st.image(APP_ICON_URL, width=80)
47
+ with col2:
48
+ st.header(f"Credit Card Prediction App")
49
+ st.caption(f"App developed by [Alsello](https://github.com/AlselloDM)")
50
+ st.write(f"This application predicts whether your credit card application is **Approved** or **Not Approved**.")
51
+ st.markdown("___")
52
+
53
+ @st.cache_data
54
+ def fetch_data():
55
+ df = pd.read_csv('Application_Data.csv')
56
+ return df
57
+
58
+ df = fetch_data()
59
+
60
+ st.sidebar.title("Approval App 📋")
61
+ st.sidebar.write('Please choose the page')
62
+ #make two pages for EDA and Prediction
63
+ page = st.sidebar.selectbox('Choose a page', ['EDA', 'Approval Form📋'])
64
+ if page == 'EDA':
65
+
66
+ st.subheader('Approval Status')
67
+ st.write('Approval Status is the target variable with value of 0 (not approved) and 1 (approved).')
68
+ sns.countplot(x='Status', data=df)
69
+ plt.xticks([0, 1])
70
+ st.pyplot(plt)
71
+ st.write('The data is imbalanced.')
72
+
73
+ st.subheader('Correlation between Years Employed and Total Income')
74
+ st.write('Years Employed and Total Income usually has correlation.')
75
+ plt.figure(figsize=(8, 6))
76
+ plt.scatter(df['Years_of_Working'], df['Total_Income'], alpha=0.5)
77
+ plt.xlabel('Years Employed')
78
+ plt.ylabel('Total Income')
79
+ plt.title('Correlation between Years Employed and Total Income')
80
+ st.pyplot(plt)
81
+ st.write('We can see that the longer the Years Employed, it does not increase the Total Income.')
82
+ st.write('')
83
+
84
+ st.subheader('Correlation of the Features')
85
+ st.write("One of the many Feature Selection Methods is Pearson's Heatmap Correlation Method.")
86
+ plt.figure(figsize=(15,15))
87
+ sns.heatmap(df.corr(), annot=True)
88
+ plt.show()
89
+ st.pyplot(plt)
90
+ st.write("There are no good enough features to choose so I used another method called 'SelectKBest'.")
91
+ st.write('')
92
+
93
+
94
+ else:
95
+ st.sidebar.title("Applicant's Profile")
96
+ st.sidebar.write('Please enter the needed profile here')
97
+ def user_input_features():
98
+ # Applicant ID
99
+ id = st.number_input("ID of the applicant (7 Digits of your ID)")
100
+ # Male or Female
101
+ sex = st.selectbox('Gender',('M','F'))
102
+ # Car Ownership
103
+ car_ownership = st.selectbox('Car Ownership (1 : Yes | 0 : No)',(1,0))
104
+ # Property Ownership
105
+ property_ownership = st.selectbox('Property Ownership (1 : Yes | 0 : No)',(1,0))
106
+ # Total Children
107
+ total_children = st.slider('Number of Children?',0,5,0)
108
+ # Income
109
+ income = st.number_input('Yearly Income',27000,1575000)
110
+ # Income Type
111
+ income_type = st.selectbox("Employment Status",('Working','Commercial associate ','State servant','Pensioner','Student'))
112
+ # Education Level
113
+ education = st.selectbox("Education Level",('Lower secondary','Secondary / secondary special','Incomplete higher ','Higher education ','Academic degree'))
114
+ # Marriage Status
115
+ marriage_status = st.selectbox("Marriage Status",('Single / not married','Married','Civil marriage','Separated','Widow'))
116
+ # Residence
117
+ residence = st.selectbox('Residency',('House / apartment','With parents','Municipal apartment','Rented apartment','Office apartment','Co-op apartment'))
118
+ # Mobile Phone Ownership
119
+ mobile_phone = st.selectbox('Mobile Phone Ownership (1 : True | 0 : False)',(1,0))
120
+ # Work Phone Ownership
121
+ work_phone = st.selectbox('Work Phone Ownership (1 : True | 0 : False)',(1,0))
122
+ # Phone Ownership
123
+ phone = st.selectbox('Phone Ownership (1 : True | 0 : False)',(1,0))
124
+ # Email Ownership
125
+ email = st.selectbox('Email Ownership (1 : True | 0 : False)',(1,0))
126
+ # Job Title
127
+ job_title = st.selectbox('Job Title',('Laborers','Core staff','Sales staff','Managers','Drivers','High skill tech staff','Accountants','Medicine staff','Cooking staff','Security staff','Cleaning staff','Private service staff','Low-skill Laborers','Waiters/barmen staff','Secretaries','HR staff','Realty agents','IT staff'))
128
+ # Total Family Member
129
+ total_family = st.slider('Number of Family Member',1,7,1)
130
+ # Applicant Age
131
+ age = st.number_input("Age")
132
+ # Years of Working
133
+ years_of_working = st.number_input("Years of Work")
134
+ # Total Bad Debt
135
+ total_bad_debt = st.slider('Total of Bad Debt',0,49,0)\
136
+ # Total Good Debt
137
+ total_good_debt = st.slider('Total of Good Debt',1,61,1)
138
+
139
+
140
+
141
+
142
+ data = {'Applicant_ID': id,'Applicant_Gender':sex,'Owned_Car':car_ownership,
143
+ 'Owned_Realty':property_ownership,'Total_Children':total_children,
144
+ 'Total_Income':income,'Income_Type':income_type,
145
+ 'Education_Type':education,'Family_Status':marriage_status,
146
+ 'Housing_Type':residence,'Owned_Mobile_Phone':mobile_phone,'Owned_Work_Phone':work_phone,
147
+ 'Owned_Phone':phone,'Owned_Email':email,'Job_Title':job_title,'Total_Family_Members':total_family,
148
+ 'Applicant_Age':age,'Years_of_Working':years_of_working,
149
+ 'Total_Bad_Debt':total_bad_debt,'Total_Good_Debt':total_good_debt}
150
+ #
151
+ features = pd.DataFrame(data,index=[0])
152
+ return features
153
+
154
+ input_df = user_input_features()
155
+
156
+ st.subheader('Applicant Data📋')
157
+ st.write(input_df)
158
+
159
+ load_model = joblib.load("model")
160
+
161
+
162
+ if st.button('Predict'):
163
+ try:
164
+ prediction = load_model.predict(input_df)
165
+ prediction_proba = load_model.predict_proba(input_df)
166
+
167
+ st.subheader('APPROVAL')
168
+ for i in range(len(prediction)):
169
+ if prediction[i] == 0:
170
+ st.error("This applicant is not **Approved**")
171
+ else:
172
+ st.success("This applicant is **Approved**")
173
+
174
+ st.subheader('Probability')
175
+ st.write("0 : No | 1 : Yes")
176
+ st.write(prediction_proba)
177
+
178
+ except ValueError:
179
+ st.header("Insufficient Applicant Data")
credit-card.png ADDED
h8dsft_P1M2_AlselloDM.ipynb ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5a7814b40a00ac7b609b62352d4f87419c9a30ce614a096a622960656ba31228
3
+ size 36101976
model ADDED
Binary file (43.5 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ matplotlib
4
+ joblib
5
+ seaborn
6
+ imblearn
7
+ scikit-learn==1.1.1
8
+ feature_engine==1.5.2