File size: 2,026 Bytes
185e396
 
83c769d
185e396
063817d
185e396
63e169b
 
063817d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185e396
 
 
 
063817d
 
 
185e396
 
 
 
063817d
 
 
 
 
 
185e396
063817d
 
 
 
185e396
 
 
 
 
063817d
185e396
063817d
185e396
063817d
185e396
063817d
185e396
 
063817d
 
 
185e396
 
 
 
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
import streamlit as st
import numpy as np
import pickle5 as pkl
import sklearn

model = pkl.load(open("model.pkl", "rb"))

st.title("Churn Modelling")

st.sidebar.header("Enter the customer details:")

# Credit Score
credit_score = st.sidebar.number_input("Credit Score", min_value=0, max_value=1000)

# Age
age = st.sidebar.number_input("Age", min_value=0, max_value=100)

# Tenure
tenure = st.sidebar.number_input("Tenure", min_value=0, max_value=100)

# Balance
balance = st.sidebar.number_input("Balance", min_value=0, max_value=100000)

# Num of Products
num_of_products = st.sidebar.number_input("Num of Products", min_value=0, max_value=10)

# Has Cr Card
has_cr_card = st.sidebar.radio("Has Cr Card", ("Yes", "No"))
if has_cr_card == "Yes":
    has_cr_card = 1
else:
    has_cr_card = 0

# Is Active Member
is_active_member = st.sidebar.radio("Is Active Member", ("Yes", "No"))
if is_active_member == "Yes":
    is_active_member = 1
else:
    is_active_member = 0

# Estimated Salary
estimated_salary = st.sidebar.number_input("Estimated Salary", min_value=0, max_value=100000)

# Female
gender = st.sidebar.selectbox("Enter your gender", ("Male", "Female"))
country = st.sidebar.selectbox("Enter your Country", ("france", "Spain", "germany"))

# Predict the customer's churn status
if st.sidebar.button("Predict"):

    if gender == "Male":
        female, male = 0, 1
    elif gender == "Female":
        female, male = 1, 0

    if country == "france":
        france, germany, spain = 1, 0, 0
    elif country == "germany":
        france, germany, spain = 0, 1, 0
    else:
        france, germany, spain = 0, 0, 1

    features = [credit_score, age, tenure, balance, num_of_products, has_cr_card, is_active_member, estimated_salary,
                female, male, france, germany, spain]
    prediction = model.predict([features])

    # Display the prediction
    if prediction == 1:
        st.write("The customer is predicted to exit the bank")
    else:
        st.write("the customer will not exit the bank")