ianyusuf commited on
Commit
b534a35
·
verified ·
1 Parent(s): 629e304

Upload 6 files

Browse files
Files changed (5) hide show
  1. .gitattributes +1 -0
  2. app.py +4 -2
  3. bank_portugal.jpg +3 -0
  4. eda.py +5 -6
  5. 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
- page = st.sidebar.selectbox('Pilih Halaman: ', ('Exploratory Data Analysis', 'Prediction'))
6
 
7
- if page == 'EDA':
 
 
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

  • SHA256: 8e6bcbce3e5486fb786e92b9e540546198ddc8dc44fdde699fd9da21f1694391
  • Pointer size: 132 Bytes
  • Size of remote file: 1.5 MB
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
- #Membuat title
11
  st.title('Bank Marketing Classification')
12
 
13
- #Tambahkan gambar
14
- image = Image.open("banco_de_portugal.png")
15
  st.image(image)
16
 
17
- st.write('---')
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 = 25, help = 'Isi usia user')
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
- #Conctact
31
- contact = st.number_input('Conctact: ', min_value = 18, max_value = 100, value = 25, help = 'Isi usia user')
32
 
33
- #Conctact
34
- duration = st.number_input('Conctact: ', min_value = 18, max_value = 100, value = 25, help = 'Isi usia user')
35
 
36
- #Conctact
37
- campaign = st.number_input('Conctact: ', min_value = 18, max_value = 100, value = 25, help = 'Isi usia user')
38
 
39
- #Conctact
40
- previous = st.number_input('Conctact: ', min_value = 18, max_value = 100, value = 25, help = 'Isi usia user')
41
 
42
- #Conctact
43
- outcome = st.number_input('Conctact: ', min_value = 18, max_value = 100, value = 25, help = 'Isi usia user')
44
 
45
  st.markdown('---')
46
 
47
  #High Skill Job
48
- job_high_skill = st.selectbox('High Skill Job : ', (1, 0), index = 0)
49
 
50
  #High Skill Job
51
- job_low_skill = st.selectbox('Low Skill Job : ', (1, 0), index = 0)
52
 
53
  #High Skill Job
54
- job_no_skill = st.selectbox('No Skill Job : ', (1, 0), index = 0)
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 Loan' : housing,
66
- 'Personal Loan' : loan,
67
- 'Communication type' : contact,
68
- 'Last contact duration' : duration,
69
- 'Number of marketing team contact' : campaign,
70
- 'Number of marketing team contact before' : previous,
71
- 'Outcome of the previous marketing campaign' : outcome,
72
- 'High Skill Job' : job_high_skill,
73
- 'Low Skill Job' : job_low_skill,
74
- 'No Skill Job' : job_no_skill
75
  }
76
 
77
  data_inf = pd.DataFrame([data_inf])
78
  st.dataframe(data_inf)
79
-
80
 
81
- #Jika tombol submit ditekan
 
82
  if submitted:
83
- #predict using linear reg model
84
  y_pred_inf = model.predict(data_inf)
85
-
86
- st.write('### Subcribed or no? ', str(int(y_pred_inf)))
 
 
 
 
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()