File size: 6,952 Bytes
e71ba74 6af2264 74eeea3 3bd361b e71ba74 346f457 3bd361b e71ba74 3bd361b a398d06 e71ba74 3a35fc6 e71ba74 14b89c2 8e3a8b4 14b89c2 df6e510 14b89c2 9527ccf e71ba74 e52f1a2 9527ccf 68de82b e71ba74 e52f1a2 a398d06 68de82b e71ba74 a398d06 9527ccf e71ba74 a398d06 9527ccf e71ba74 a398d06 9527ccf e71ba74 a398d06 9527ccf e71ba74 a398d06 9527ccf e71ba74 81b2eea 3b6385c e71ba74 2c60263 3b6385c 2c60263 3b6385c e71ba74 3b6385c 247e317 3b6385c 247e317 55c37bb 247e317 ba8059e 247e317 03acf00 | 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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | import streamlit as st
import joblib
import numpy as np
html_temp = """
<div style="background-color:black;padding:10px">
<h2 style="color:white;text-align:center;">Banking Churn Model App </h2>
</div>
"""
st.markdown(html_temp, unsafe_allow_html=True)
bg_image_url = "https://wallpaperbat.com/img/11547497-download-modern-bank-interior.jpg " # Replace with your image URL
# Inject CSS with background image
st.markdown(f"""
<style>
.stApp {{
background-image: url("{bg_image_url}");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
}}
</style>
""", unsafe_allow_html=True)
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #e40c2b ;">
{ "Enter the customer details:"}
</div>
""", unsafe_allow_html=True)
# model
bank_model=joblib.load("bank_churn_svc_model.joblib")
# Input variables
st.write("")
col1, col2 = st.columns(2)
with col1:
## CreditScore
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Slide the Credit Score Value:"}
</div>
""", unsafe_allow_html=True)
credit_score=st.slider("",min_value=350,max_value=850)
with col2:
## Geography
option_geo=["France","Spain","Germany"]
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Select the Geography:"}
</div>
""", unsafe_allow_html=True)
geo=st.selectbox("",options=option_geo)
geography_value=option_geo.index(geo)
col1, col2 = st.columns(2)
with col1:
## gender
option_gen=["Female "," Male"]
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Select the Gender:"}
</div>
""", unsafe_allow_html=True)
gen=st.selectbox("",option_gen)
gender_value=option_gen.index(gen)
with col2:
## Age
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Enter your AGE:"}
</div>
""", unsafe_allow_html=True)
age=st.number_input("",max_value=92,min_value=18)
col1,col2=st.columns(2)
with col1:
## Tenure
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Slide the Tenure of the Loan:"}
</div>
""", unsafe_allow_html=True)
tenure=st.slider("",min_value=0,max_value=10)
with col2:
## Balance
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Slide The Balance Of the your Account:"}
</div>
""", unsafe_allow_html=True)
balance=st.slider("",min_value=0.0,max_value=250898.09)
col1,col2=st.columns(2)
with col1:
## IsActiveMember
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Are you Active Account Holder:"}
</div>
""", unsafe_allow_html=True)
active_holder= st.radio("", ["YES", "NO"])
if active_holder=="YES":
active_holder_value=1
else:
active_holder_value=0
with col2:
## EstimatedSalary
st.markdown(f"""
<div style="
padding: 15px;
background-color: #f7f4e9;
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: #1ba098;">
{ "Silde the Salary:"}
</div>
""", unsafe_allow_html=True)
e_salary=st.slider("",max_value=199992,min_value=11)
if st.button("Submit"):
try:
# Scaler the values
credit_score=np.round(((credit_score-650.528800)/96.653299),3)
age=np.round(((age-38.921800)/10.487806),3)
tenure=np.round(((tenure-5.012800)/2.8921740),3)
balance=np.round(((balance-76485.889288)/62397.405202),3)
e_salary=np.round(((e_salary-100090.239881)/57510.492818),3)
prediction = bank_model.predict([[credit_score, geography_value, gender_value, age, tenure, balance, e_salary, active_holder_value]])[0]
# Define messages and colors
review_status = {
0: ("✅ The Customer is Interseted in our Bank", "#32CD32"), # Green
1: ("❌ The Customer is Not Interseted in our Bank", "#FF4500") # Red-Orange
}
# Get message and color based on prediction
message, color = review_status.get(prediction, ("❓ Unknown Prediction", "#808080"))
# Display styled result
st.markdown(f"""
<div style="
padding: 15px;
background-color: {color};
border-radius: 10px;
text-align: center;
font-size: 18px;
font-weight: bold;
color: white;">
{message}
</div>
""", unsafe_allow_html=True)
except Exception as e:
st.error(f"⚠️ Error in prediction: {e}")
# st.write("")
|