melisagunawan17 commited on
Commit
5e5767a
·
verified ·
1 Parent(s): c5353a7

Delete deployment.py

Browse files
Files changed (1) hide show
  1. deployment.py +0 -77
deployment.py DELETED
@@ -1,77 +0,0 @@
1
- import streamlit as st
2
- import pandas as pd
3
- import joblib
4
-
5
- st.header('FTDS Model Deployment')
6
-
7
- st.write("""
8
- Created by Maria Melisa Gunawan
9
-
10
- Use the sidebar to select input features.
11
- """)
12
-
13
- @st.cache
14
- def fetch_data():
15
- df = pd.read_csv('P1G5_Set_1_Melisa.csv')
16
- return df
17
-
18
- df = fetch_data()
19
- st.write(df)
20
-
21
- st.sidebar.header('User Input Features')
22
-
23
- # Fungsi untuk mengambil input dari pengguna
24
- def user_input():
25
- pay_0 = st.sidebar.number_input('Payment Status in September (pay_0)', value=80000)
26
- pay_2 = st.sidebar.number_input('Payment Status in August (pay_2)', value=20000)
27
- pay_3 = st.sidebar.number_input('Payment Status in July (pay_3)', value=3000)
28
- pay_4 = st.sidebar.number_input('Payment Status in June (pay_4)', value=45000)
29
- pay_5 = st.sidebar.number_input('Payment Status in May (pay_5)', value=500)
30
- pay_6 = st.sidebar.number_input('Payment Status in April (pay_6)', value=2500)
31
- limit_balance = st.sidebar.number_input('Credit Limit (limit_balance)', value=90000)
32
- default_payment_next_month = st.sidebar.selectbox('Default Payment Next Month', ['No', 'Yes'])
33
-
34
- # Mapping 'No' to 0 and 'Yes' to 1
35
- default_payment_next_month = 1 if default_payment_next_month == 'Yes' else 0
36
-
37
- data = {
38
- 'pay_0': pay_0,
39
- 'pay_2': pay_2,
40
- 'pay_3': pay_3,
41
- 'pay_4': pay_4,
42
- 'pay_5': pay_5,
43
- 'pay_6': pay_6,
44
- 'limit_balance': limit_balance,
45
- 'default_payment_next_month': default_payment_next_month
46
- }
47
- features = pd.DataFrame(data, index=[0])
48
- return features
49
-
50
- # Memuat model yang telah di-train
51
- load_model = joblib.load("credit_card_default_model.pkl")
52
-
53
- # Menjalankan aplikasi Streamlit
54
- def main():
55
- st.title('Default Payment Next Month')
56
-
57
- # Mengambil input dari pengguna
58
- input_features = user_input()
59
-
60
- # Menampilkan input pengguna
61
- st.subheader('User Input')
62
- st.write(input_features)
63
-
64
- # Melakukan prediksi menggunakan model
65
- prediction = load_model.predict(input_features)
66
-
67
- if prediction == 1:
68
- prediction = 'Default'
69
- else:
70
- prediction = 'Not Default'
71
-
72
- # Menampilkan hasil prediksi
73
- st.subheader('Prediction')
74
- st.write(f'Based on user input, the model predicts: {prediction}')
75
-
76
- if __name__ == '__main__':
77
- main()