Update app.py
Browse files
app.py
CHANGED
|
@@ -1,83 +1,94 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import joblib
|
| 3 |
-
import numpy as np
|
| 4 |
-
html_temp = """
|
| 5 |
-
<div style="background-color:black;padding:10px">
|
| 6 |
-
<h2 style="color:white;text-align:center;">Banking Churn Model App </h2>
|
| 7 |
-
</div>
|
| 8 |
-
"""
|
| 9 |
-
st.markdown(html_temp, unsafe_allow_html=True)
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
col1, col2 = st.columns(2)
|
| 31 |
-
with col1:
|
| 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 |
-
if
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import joblib
|
| 3 |
+
import numpy as np
|
| 4 |
+
html_temp = """
|
| 5 |
+
<div style="background-color:black;padding:10px">
|
| 6 |
+
<h2 style="color:white;text-align:center;">Banking Churn Model App </h2>
|
| 7 |
+
</div>
|
| 8 |
+
"""
|
| 9 |
+
st.markdown(html_temp, unsafe_allow_html=True)
|
| 10 |
+
st.markdown(f"""
|
| 11 |
+
<style>
|
| 12 |
+
/* Set the background image for the entire app */
|
| 13 |
+
.stApp {{
|
| 14 |
+
background-color#abf62d;
|
| 15 |
+
background-size: 100px;
|
| 16 |
+
background-repeat:no;
|
| 17 |
+
background-attachment: auto;
|
| 18 |
+
background-position:full;
|
| 19 |
+
}}
|
| 20 |
+
</style>
|
| 21 |
+
""", unsafe_allow_html=True)
|
| 22 |
+
st.write("Enter the customer details:")
|
| 23 |
+
|
| 24 |
+
# model
|
| 25 |
+
|
| 26 |
+
bank_model=joblib.load("bank_churn_svc_model.joblib")
|
| 27 |
+
|
| 28 |
+
# Input variables
|
| 29 |
+
|
| 30 |
+
col1, col2 = st.columns(2)
|
| 31 |
+
with col1:
|
| 32 |
+
## CreditScore
|
| 33 |
+
credit_score=st.slider("Slide the Credit Score Value:",min_value=350,max_value=850)
|
| 34 |
+
|
| 35 |
+
with col2:
|
| 36 |
+
## Geography
|
| 37 |
+
option_geo=["France","Spain","Germany"]
|
| 38 |
+
geo=st.selectbox("Select The Geography: ",options=option_geo)
|
| 39 |
+
geography_value=option_geo.index(geo)
|
| 40 |
+
|
| 41 |
+
col1, col2 = st.columns(2)
|
| 42 |
+
with col1:
|
| 43 |
+
## gender
|
| 44 |
+
option_gen=["Female "," Male"]
|
| 45 |
+
gen=st.selectbox("Select the Gender",option_gen)
|
| 46 |
+
gender_value=option_gen.index(gen)
|
| 47 |
+
with col2:
|
| 48 |
+
## Age
|
| 49 |
+
age=st.number_input("Enter your AGE:",max_value=92,min_value=18)
|
| 50 |
+
|
| 51 |
+
col1,col2=st.columns(2)
|
| 52 |
+
with col1:
|
| 53 |
+
## Tenure
|
| 54 |
+
tenure=st.slider("Slide the Tenure of the Loan:",min_value=0,max_value=10)
|
| 55 |
+
|
| 56 |
+
with col2:
|
| 57 |
+
## Balance
|
| 58 |
+
balance=st.slider("Slide The Balance Of the your Account:",min_value=0.0,max_value=250898.09)
|
| 59 |
+
|
| 60 |
+
col1,col2=st.columns(2)
|
| 61 |
+
|
| 62 |
+
with col1:
|
| 63 |
+
## IsActiveMember
|
| 64 |
+
active_holder= st.radio("Are you Active Account Holder:", ["YES", "NO"])
|
| 65 |
+
if active_holder=="YES":
|
| 66 |
+
active_holder_value=1
|
| 67 |
+
else:
|
| 68 |
+
active_holder_value=0
|
| 69 |
+
|
| 70 |
+
with col2:
|
| 71 |
+
## EstimatedSalary
|
| 72 |
+
e_salary=st.slider("Silde the Salary :",max_value=199992,min_value=11)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
if st.button("Submit"):
|
| 77 |
+
|
| 78 |
+
# Scaler the values
|
| 79 |
+
|
| 80 |
+
credit_score=np.round(((credit_score-650.528800)/96.653299),3)
|
| 81 |
+
age=np.round(((age-38.921800)/10.487806),3)
|
| 82 |
+
tenure=np.round(((tenure-5.012800)/2.8921740),3)
|
| 83 |
+
balance=np.round(((balance-76485.889288)/62397.405202),3)
|
| 84 |
+
e_salary=np.round(((e_salary-100090.239881)/57510.492818),3)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
output = bank_model.predict([[credit_score, geography_value, gender_value, age, tenure, balance, e_salary, active_holder_value]])
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
if output ==0:
|
| 91 |
+
st.write("The Customer is Interseted in our Bank")
|
| 92 |
+
else:
|
| 93 |
+
st.write("The Customer is Not Interseted in our Bank")
|
| 94 |
|