mkManishKumar
commited on
Commit
•
f715252
1
Parent(s):
a6762e1
Upload 5 files
Browse files- StandardScaler.joblib +3 -0
- app.py +67 -0
- bank-customer-churn.ipynb +0 -0
- encoders .joblib +3 -0
- rf_model.joblib +3 -0
StandardScaler.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:51b4d79ee8f10b1e6511e55c6f9d03f467a9f48538e7a6d0eb941de5bf8c0587
|
3 |
+
size 1303
|
app.py
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import streamlit as st
|
3 |
+
import pandas as pd
|
4 |
+
|
5 |
+
def main():
|
6 |
+
st.title("Bank Customer Churn")
|
7 |
+
|
8 |
+
credit_score = st.number_input("Credit Score")
|
9 |
+
country = st.selectbox("Country", options=['France', 'Spain', 'Germany'])
|
10 |
+
|
11 |
+
if country:
|
12 |
+
st.success(country)
|
13 |
+
|
14 |
+
gender = st.radio("Select Gender: ", ('Male', 'Female'))
|
15 |
+
if (gender == 'Male'):
|
16 |
+
st.success("Male")
|
17 |
+
else:
|
18 |
+
st.success("Female")
|
19 |
+
|
20 |
+
age = st.number_input("Age")
|
21 |
+
tenure = st.number_input("Tenure")
|
22 |
+
balance = st.number_input("Balance")
|
23 |
+
products_number = st.number_input("Products Number")
|
24 |
+
credit_card = st.number_input("Credit Card")
|
25 |
+
active_member = st.number_input("Active Member")
|
26 |
+
estimated_salary = st.number_input("Estimated Salary")
|
27 |
+
submit_button = st.button("Submit")
|
28 |
+
|
29 |
+
if submit_button:
|
30 |
+
# Process the form data
|
31 |
+
process_form_data(credit_score, country, gender, age, tenure,
|
32 |
+
balance, products_number, credit_card, active_member, estimated_salary)
|
33 |
+
|
34 |
+
def process_form_data(credit_score, country, gender, age, tenure,
|
35 |
+
balance, products_number, credit_card, active_member, estimated_salary):
|
36 |
+
|
37 |
+
|
38 |
+
encoders = joblib.load('encoders .joblib')
|
39 |
+
model = joblib.load('rf_model.joblib')
|
40 |
+
scaler = joblib.load('StandardScaler.joblib')
|
41 |
+
|
42 |
+
|
43 |
+
dataDict = {'credit_score': credit_score, 'country': country, 'gender': gender, 'age': age, 'tenure':tenure,
|
44 |
+
'balance':balance, 'products_number': products_number, 'credit_card': credit_card,
|
45 |
+
'active_member': active_member, 'estimated_salary': estimated_salary}
|
46 |
+
|
47 |
+
df = pd.DataFrame([dataDict])
|
48 |
+
|
49 |
+
decodedData = df.copy()
|
50 |
+
for col in ['country', 'gender']:
|
51 |
+
encoder = encoders[col]
|
52 |
+
decodedData[col] = encoder.transform(decodedData[col])
|
53 |
+
#
|
54 |
+
decodedData = scaler.transform(decodedData)
|
55 |
+
result = model.predict(decodedData)
|
56 |
+
|
57 |
+
st.write(df)
|
58 |
+
|
59 |
+
if result == 1:
|
60 |
+
st.warning("Churn")
|
61 |
+
if result == 0:
|
62 |
+
st.success("Stay")
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
if __name__ == "__main__":
|
67 |
+
main()
|
bank-customer-churn.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
encoders .joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7fd52bc3fae6cf62b4c8b9ceef029bb68e19523253480aeda8580ea92faa815d
|
3 |
+
size 852
|
rf_model.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1ee0a2c33a3af1181465f543f11989f6b7ad0df9c3dc2a89f78c9c21bd94b392
|
3 |
+
size 13516809
|