Muhamadinsani17 commited on
Commit
15c496e
·
1 Parent(s): 046fa6b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import joblib
4
+
5
+ st.header('FTDS Model Deployment')
6
+ st.write("""
7
+ Created by FTDS Curriculum Team
8
+ Use the sidebar to select input features.
9
+ """)
10
+
11
+ @st.cache
12
+ def fetch_data():
13
+ df = pd.read_csv('P1G5_Set_1_Muhammad-Insani.csv')
14
+ return df
15
+
16
+ df = fetch_data()
17
+ st.write(df)
18
+
19
+ st.sidebar.header('User Input Features')
20
+
21
+ def user_input():
22
+ limit_balance = st.sidebar.selectbox('limit_balance', df['limit_balance'].unique())
23
+ pay_1 = st.slider('pay_1', min_value=-12, max_value=12)
24
+ pay_2 = st.slider('pay_2', min_value=-12, max_value=12)
25
+ pay_3 = st.slider('pay_3', min_value=-12, max_value=12)
26
+ pay_4 = st.slider('pay_4', min_value=-12, max_value=12)
27
+ pay_5 = st.slider('pay_5', min_value=-12, max_value=12)
28
+ pay_6 = st.slider('pay_6', min_value=-12, max_value=12)
29
+
30
+ data = {
31
+ 'limit_balance': limit_balance,
32
+ 'pay_1': pay_1,
33
+ 'pay_2': pay_2,
34
+ 'pay_3': pay_3,
35
+ 'pay_4': pay_4,
36
+ 'pay_5': pay_5,
37
+ 'pay_6': pay_6
38
+ }
39
+ features = pd.DataFrame(data, index=[0])
40
+ return features
41
+
42
+
43
+ input = user_input()
44
+
45
+ st.subheader('User Input')
46
+ st.write(input)
47
+
48
+ load_model = joblib.load("my_model.pkl")
49
+
50
+ if st.button("Predict"):
51
+ prediction = load_model.predict(input)
52
+
53
+ if prediction == 1:
54
+ prediction = 'Defaulted Payment'
55
+ else:
56
+ prediction = 'Not Defaulted'
57
+
58
+ st.subheader('Based on user input, the placement model predicted: ')
59
+ st.header(prediction)