-
Notifications
You must be signed in to change notification settings - Fork 0
/
credit_app.py
82 lines (64 loc) · 2.51 KB
/
credit_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 13 09:17:21 2020
@author: prachi
"""
import streamlit as st
import pickle
import numpy as np
pks= pickle.load(open('rfmodel.pkl','rb'))
def predict_disease(*args):
input=np.array([args]).astype(np.float64)
prediction=pks.predict(input)
return int(prediction)
def main():
st.title("Credit Card Defaulter Prediction App")
html_temp="""
<div style="background-color:#025246 ;padding:10px">
<h2 style="color:white;text-align:center;">Are you a defaulter? </h2>
</div>
"""
page_bg_img = '''
<style>
body {
background-image: url("https://images.unsplash.com/photo-1589758438368-0ad531db3366?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=889&q=80");
background-size: cover;
}
</style>
'''
st.markdown(html_temp, unsafe_allow_html=True)
st.markdown(page_bg_img, unsafe_allow_html=True)
a = st.text_input("BALANCE LIMIT","Type Here")
b = st.text_input("SEX","Type Here")
c = st.text_input("AGE","Type Here")
d = st.text_input("BILL AMT1","Type Here")
e = st.text_input("BILL AMT 2","Type Here")
f = st.text_input("BILL AMT 3","Type Here")
g = st.text_input("BILL AMT 4","Type Here")
h = st.text_input("BILL AMT 5","Type Here")
i = st.text_input("BILL AMT 6","Type Here")
j = st.text_input("PAY AMT 1 ","Type Here")
k = st.text_input("PAY AMT 2","Type Here")
l = st.text_input("PAY AMT 3","Type Here")
m = st.text_input("PAY AMT 4","Type Here")
n = st.text_input("PAY AMT 5","Type Here")
o = st.text_input("PAY AMT 6","Type Here")
safe_html="""
<div style="background-color:#F4D03F;padding:10px >
<h2 style="color:white;text-align:center;">Congratulations! You have successfully managed to maintain minimum balance </h2>
</div>
"""
danger_html="""
<div style="background-color:#F08080;padding:10px >
<h2 style="color:black ;text-align:center;">Alert! You are below minimum balance.</h2>
</div>
"""
if st.button("Predict"):
output=predict_disease(a,b,c,d,e,f,g,h,i,j,k,l,m,n,o)
st.success('The probability is {}'.format(output*100))
if output == 1:
st.markdown(danger_html,unsafe_allow_html=True)
else:
st.markdown(safe_html,unsafe_allow_html=True)
if __name__=='__main__':
main()