Upload 6 files
Browse files- .gitattributes +1 -0
- app.py +4 -2
- bank_portugal.jpg +3 -0
- eda.py +5 -6
- prediction.py +37 -33
.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 |
+
bank_portugal.jpg filter=lfs diff=lfs merge=lfs -text
|
app.py
CHANGED
@@ -2,9 +2,11 @@ import streamlit as st
|
|
2 |
import eda
|
3 |
import prediction
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
|
|
|
|
8 |
eda.run()
|
9 |
else:
|
10 |
prediction.run()
|
|
|
2 |
import eda
|
3 |
import prediction
|
4 |
|
5 |
+
sc = st.sidebar.image('banco_de_portugal.png')
|
6 |
|
7 |
+
page = st.sidebar.selectbox('Select Page: ', ('Exploratory Data Analysis', 'Prediction'))
|
8 |
+
|
9 |
+
if page == 'Exploratory Data Analysis':
|
10 |
eda.run()
|
11 |
else:
|
12 |
prediction.run()
|
bank_portugal.jpg
ADDED
![]() |
Git LFS Details
|
eda.py
CHANGED
@@ -1,20 +1,19 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import seaborn as sns
|
4 |
-
import matplotlib.pyplot as plt
|
5 |
-
import plotly.express as px
|
6 |
from PIL import Image
|
7 |
|
8 |
def run():
|
9 |
|
10 |
-
#
|
11 |
st.title('Bank Marketing Classification')
|
12 |
|
13 |
-
#
|
14 |
-
image = Image.open("
|
15 |
st.image(image)
|
16 |
|
17 |
-
st.
|
18 |
st.write('## Exploratory Data Analysis')
|
19 |
|
20 |
#Load data
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import seaborn as sns
|
4 |
+
import matplotlib.pyplot as plt
|
|
|
5 |
from PIL import Image
|
6 |
|
7 |
def run():
|
8 |
|
9 |
+
#Title
|
10 |
st.title('Bank Marketing Classification')
|
11 |
|
12 |
+
#Image
|
13 |
+
image = Image.open("bank_portugal.jpg")
|
14 |
st.image(image)
|
15 |
|
16 |
+
st.markdown('---')
|
17 |
st.write('## Exploratory Data Analysis')
|
18 |
|
19 |
#Load data
|
prediction.py
CHANGED
@@ -10,7 +10,7 @@ def run():
|
|
10 |
with st.form('bank_form'):
|
11 |
|
12 |
#Age
|
13 |
-
age = st.number_input('Age: ', min_value = 18, max_value = 100, value =
|
14 |
|
15 |
#Marital
|
16 |
marital = st.selectbox('Marital : ', ('married', 'single marital', 'divorce'), index = 0)
|
@@ -27,63 +27,67 @@ def run():
|
|
27 |
#Housing Loan
|
28 |
housing = st.selectbox('Housing Loan : ', ('yes', 'no'), index = 0)
|
29 |
|
30 |
-
#
|
31 |
-
contact = st.
|
32 |
|
33 |
-
#
|
34 |
-
duration = st.number_input('
|
35 |
|
36 |
-
#
|
37 |
-
campaign = st.number_input('
|
38 |
|
39 |
-
#
|
40 |
-
previous = st.number_input('
|
41 |
|
42 |
-
#
|
43 |
-
outcome = st.
|
44 |
|
45 |
st.markdown('---')
|
46 |
|
47 |
#High Skill Job
|
48 |
-
job_high_skill = st.selectbox('High Skill Job : ', (1, 0), index =
|
49 |
|
50 |
#High Skill Job
|
51 |
-
job_low_skill = st.selectbox('Low Skill Job : ', (1, 0), index =
|
52 |
|
53 |
#High Skill Job
|
54 |
-
job_no_skill = st.selectbox('No Skill Job : ', (1, 0), index =
|
55 |
|
56 |
#Submit button
|
57 |
submitted = st.form_submit_button('Predict')
|
58 |
|
59 |
#Data Inference
|
60 |
data_inf = {
|
61 |
-
'
|
62 |
-
'
|
63 |
-
'
|
64 |
-
'
|
65 |
-
'
|
66 |
-
'
|
67 |
-
'
|
68 |
-
'
|
69 |
-
'
|
70 |
-
'
|
71 |
-
'
|
72 |
-
'
|
73 |
-
'
|
74 |
-
'
|
75 |
}
|
76 |
|
77 |
data_inf = pd.DataFrame([data_inf])
|
78 |
st.dataframe(data_inf)
|
79 |
-
|
80 |
|
81 |
-
|
|
|
82 |
if submitted:
|
83 |
-
#
|
84 |
y_pred_inf = model.predict(data_inf)
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
87 |
|
88 |
if __name__ == '__main__':
|
89 |
run()
|
|
|
10 |
with st.form('bank_form'):
|
11 |
|
12 |
#Age
|
13 |
+
age = st.number_input('Age: ', min_value = 18, max_value = 100, value = 30, help = 'Isi usia user')
|
14 |
|
15 |
#Marital
|
16 |
marital = st.selectbox('Marital : ', ('married', 'single marital', 'divorce'), index = 0)
|
|
|
27 |
#Housing Loan
|
28 |
housing = st.selectbox('Housing Loan : ', ('yes', 'no'), index = 0)
|
29 |
|
30 |
+
#Contact
|
31 |
+
contact = st.selectbox('Communication type : ', ('cellular', 'telephone', 'unknown'), index = 0)
|
32 |
|
33 |
+
#Duration
|
34 |
+
duration = st.number_input('Last contact duration: ', min_value = 0, value = 0, help = 'Isi usia user')
|
35 |
|
36 |
+
#Campaign
|
37 |
+
campaign = st.number_input('Number of marketing team contact: ', min_value = 0, value = 0, help = 'Isi usia user')
|
38 |
|
39 |
+
#Previous
|
40 |
+
previous = st.number_input('Number of marketing team contact before: ', min_value = 0, value = 0, help = 'Isi usia user')
|
41 |
|
42 |
+
#Outcome
|
43 |
+
outcome = st.selectbox('Outcome of the previous marketing campaign: ', ('failure', 'nonexistent', 'unknown', 'success'), index = 0)
|
44 |
|
45 |
st.markdown('---')
|
46 |
|
47 |
#High Skill Job
|
48 |
+
job_high_skill = st.selectbox('High Skill Job : ', (1, 0), index = 1)
|
49 |
|
50 |
#High Skill Job
|
51 |
+
job_low_skill = st.selectbox('Low Skill Job : ', (1, 0), index = 1)
|
52 |
|
53 |
#High Skill Job
|
54 |
+
job_no_skill = st.selectbox('No Skill Job : ', (1, 0), index = 1)
|
55 |
|
56 |
#Submit button
|
57 |
submitted = st.form_submit_button('Predict')
|
58 |
|
59 |
#Data Inference
|
60 |
data_inf = {
|
61 |
+
'age' : age,
|
62 |
+
'marital' : marital,
|
63 |
+
'education' : education,
|
64 |
+
'balance' : balance,
|
65 |
+
'housing' : housing,
|
66 |
+
'loan' : loan,
|
67 |
+
'contact' : contact,
|
68 |
+
'duration' : duration,
|
69 |
+
'campaign' : campaign,
|
70 |
+
'previous' : previous,
|
71 |
+
'outcome' : outcome,
|
72 |
+
'job_high_skill' : job_high_skill,
|
73 |
+
'job_low_skill' : job_low_skill,
|
74 |
+
'job_no_skill' : job_no_skill
|
75 |
}
|
76 |
|
77 |
data_inf = pd.DataFrame([data_inf])
|
78 |
st.dataframe(data_inf)
|
|
|
79 |
|
80 |
+
st.write('### Has the client subscribed a term deposit?')
|
81 |
+
|
82 |
if submitted:
|
83 |
+
# Prediction using saved models
|
84 |
y_pred_inf = model.predict(data_inf)
|
85 |
+
|
86 |
+
# Convert prediction results to text
|
87 |
+
result = "Subscribed" if int(y_pred_inf) == 1 else "Not Subscribed"
|
88 |
+
|
89 |
+
# Show Results
|
90 |
+
st.write(result)
|
91 |
|
92 |
if __name__ == '__main__':
|
93 |
run()
|