mnurbani commited on
Commit
1989cb1
1 Parent(s): 4493caf

Upload 7 files

Browse files
Files changed (7) hide show
  1. Banking Marketing.csv +0 -0
  2. Deposito.jpg +0 -0
  3. app.py +10 -0
  4. eda.py +55 -0
  5. model_rf.pkl +3 -0
  6. prediction.py +94 -0
  7. requirements.txt +8 -0
Banking Marketing.csv ADDED
The diff for this file is too large to render. See raw diff
 
Deposito.jpg ADDED
app.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import eda
3
+ import prediction
4
+
5
+ page = st.sidebar.selectbox('Pilih Halaman : ', ('Dashboard', 'Prediction'))
6
+
7
+ if page == 'Dashboard' :
8
+ eda.run()
9
+ else:
10
+ prediction.run()
eda.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ #Membuat title
10
+ st.title('Deposito Simulation')
11
+
12
+ #Tambahkan gambar
13
+ image = Image.open('Deposito.jpg')
14
+ st.image(image, caption = 'Deposito')
15
+
16
+ #Menambahkan deskripsi
17
+ st.write('Page ini dibuat oleh Mardhya Malik Nurbani')
18
+
19
+ #Membuat garis
20
+ st.markdown('----')
21
+
22
+ #Masukkan pandas dataframe
23
+
24
+ #Show dataframe
25
+ df = pd.read_csv('Banking Marketing.csv')
26
+ st.dataframe(df)
27
+
28
+ #Membuat bar plot
29
+ # st.write('#### Plot AttackingWorkRate')
30
+ # fig = plt.figure(figsize=(15,5))
31
+ # sns.countplot(x='AttackingWorkRate', data = df)
32
+ # st.pyplot(fig)
33
+
34
+ # #Membuat histogram
35
+ # st.write('#### Histogram of Age')
36
+ # fig = plt.figure(figsize=(15,5))
37
+ # sns.histplot(df['Overall'], bins = 30, kde = True)
38
+ # st.pyplot(fig)
39
+
40
+ # #membuat histogram berdasarkan inputan user
41
+ # st.write('#### Histogram berdasarkan input user')
42
+ # #kalo mau pake radio button, ganti selectbox jadi radio
43
+ # option = st.selectbox('Pilih Column : ', ('Age', 'Weight', 'Height', 'ShootingTotal'))
44
+ # fig = plt.figure(figsize= (15,5))
45
+ # sns.histplot(df[option], bins = 30, kde = True)
46
+ # st.pyplot(fig)
47
+
48
+ # #Membuat Plotly plot
49
+
50
+ # st.write('#### Plotly Plot - ValueEUR vs Overall')
51
+ # fig = px.scatter(df, x = 'ValueEUR', y = 'Overall', hover_data = ['Name', 'Age'])
52
+ # st.plotly_chart(fig)
53
+
54
+ if __name__ == '__main__':
55
+ run()
model_rf.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a744cb5943a7967f73796630256a9b43409871a3869784c11716314f6914ecc
3
+ size 3708728
prediction.py ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import joblib, pickle
5
+ import json
6
+
7
+ #Load All Files
8
+
9
+ #load model dan files yang sudah di save pada framing
10
+ # with open('model_rf.pkl', 'rb') as file_1:
11
+ # model_rf = pickle.load(file_1)
12
+ # # model_patch = 'model_rf.pkl'
13
+ # model_rf = joblib.load(model_patch)
14
+ # with open('list_num_cols.txt', 'r') as file_1:
15
+ # list_num_cols = json.load(file_1)
16
+ # with open('list_cat_cols.txt', 'r') as file_2:
17
+ # list_cat_cols = json.load(file_2)
18
+ with open('model_rf.pkl', 'rb') as file3:
19
+ loaded_model = pickle.load(file3)
20
+
21
+ def run():
22
+
23
+ with st.form('deposito_simulation'):
24
+ #Field Umur
25
+ Age = st.number_input('Age', min_value = 17, max_value = 75, value = 25, step = 1, help = 'Customers Age')
26
+ #Field Nama
27
+ Job = st.selectbox('Job', ('admin.', 'technician', 'services','management','retired','blue-collar','unemployed','entrepreneur','housemaid','unknown','self-employed','student'), index = 1)
28
+ #Marital Status
29
+ Marital = st.selectbox('Marital Status', ('married', 'single', 'divorced'), index = 1)
30
+ #Education Status
31
+ Education = st.selectbox('Education', ('secondary', 'tertiary', 'primary', 'unknown'), index = 1)
32
+ #Default Status
33
+ Default = st.selectbox('Default', ('no', 'yes'), index = 1, help = 'has credit in default?')
34
+ #Field Pace Total
35
+ Balance = st.number_input('Balance', min_value = 0, max_value=999999, value = 50)
36
+ #Housing Status
37
+ Housing = st.selectbox('Housing', ('yes', 'no'), index = 1, help = 'has housing loan?')
38
+ #Loan Status
39
+ Loan = st.selectbox('Loan', ('no', 'yes'), index = 1, help = 'has personal loan?')
40
+ #Contact Status
41
+ Contact = st.selectbox('Contact', ('unknown', 'cellular', 'telephone'), index = 1)
42
+ #Day
43
+ Day = st.number_input('Day', min_value = 1, max_value=31, value = 1, help = 'last contact day of the month')
44
+ #Month
45
+ Month = st.selectbox('Month', ('may', 'jun', 'jul', 'aug', 'oct', 'nov', 'dec', 'jan', 'feb', 'mar', 'apr', 'sep'), index = 1, help = 'last contact month of year')
46
+ #Duration
47
+ Duration = st.number_input('Duration', min_value = 0, max_value=999999, value = 50, help = 'last contact duration, in seconds')
48
+ #Day
49
+ Campaign = st.number_input('Campaign', min_value = 1, max_value=100, value = 1, help = 'number of contacts performed during this campaign and for this client')
50
+ #pDyas
51
+ Pdays = st.number_input('Pdays', min_value = -1 , max_value=9999999, value = 0, help = 'number of days that passed by after the client was last contacted from a previous campaign (numeric, -1 means client was not previously contacted')
52
+ #Previous
53
+ Previous = st.number_input('Previous', min_value = 0, max_value=100, value = 0, help = 'previous: number of contacts performed before this campaign and for this client')
54
+ #Poutcome Status
55
+ Poutcome = st.selectbox('P Outcome', ('unknown', 'other', 'failure', 'success'), index = 1, help = 'outcome of the previous marketing campaign')
56
+
57
+
58
+ #bikin submit button
59
+ submitted = st.form_submit_button('Predict')
60
+
61
+ #Inference
62
+ data_inf = {
63
+ 'age' : Age,
64
+ 'job' : Job,
65
+ 'marital' : Marital,
66
+ 'education' : Education,
67
+ 'default' : Default,
68
+ 'balance' : Balance,
69
+ 'housing' :Housing,
70
+ 'loan': Loan,
71
+ 'contact' : Contact,
72
+ 'day' :Day,
73
+ 'month' :Month,
74
+ 'duration':Duration,
75
+ 'campaign': Campaign,
76
+ 'pdays':Pdays,
77
+ 'previous':Previous,
78
+ 'poutcome': Poutcome,
79
+ }
80
+
81
+ data_inf = pd.DataFrame([data_inf])
82
+ st.dataframe(data_inf)
83
+
84
+ #Logic ketika predic button ditekan
85
+
86
+ if submitted:
87
+
88
+ #predict using pipe rf model
89
+ predictions = loaded_model.predict(data_inf)
90
+
91
+ st.write('## Deposit : ', str(int(predictions)))
92
+
93
+ if __name__ == '__main__':
94
+ run()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ seaborn
4
+ matplotlib
5
+ numpy
6
+ plotly
7
+ pillow
8
+ scikit-learn==1,2.2