Spaces:
Sleeping
Sleeping
Commit ·
063817d
1
Parent(s): 21ab61f
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,4 +1,59 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
st.title("Churn Modelling")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import numpy as np
|
| 3 |
+
import pickle as pkl
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
model = pickle.load(open("model.pkl","rb"))
|
| 7 |
|
| 8 |
st.title("Churn Modelling")
|
| 9 |
+
|
| 10 |
+
st.sidebar.header("Enter the customer details:")
|
| 11 |
+
|
| 12 |
+
# Credit Score
|
| 13 |
+
credit_score = st.sidebar.number_input("Credit Score", min_value=0, max_value=1000)
|
| 14 |
+
|
| 15 |
+
# Age
|
| 16 |
+
age = st.sidebar.number_input("Age", min_value=0, max_value=100)
|
| 17 |
+
|
| 18 |
+
# Tenure
|
| 19 |
+
tenure = st.sidebar.number_input("Tenure", min_value=0, max_value=100)
|
| 20 |
+
|
| 21 |
+
# Balance
|
| 22 |
+
balance = st.sidebar.number_input("Balance", min_value=0, max_value=100000)
|
| 23 |
+
|
| 24 |
+
# Num of Products
|
| 25 |
+
num_of_products = st.sidebar.number_input("Num of Products", min_value=0, max_value=10)
|
| 26 |
+
|
| 27 |
+
# Has Cr Card
|
| 28 |
+
has_cr_card = st.sidebar.radio("Has Cr Card", ("Yes", "No"))
|
| 29 |
+
|
| 30 |
+
# Is Active Member
|
| 31 |
+
is_active_member = st.sidebar.radio("Is Active Member", ("Yes", "No"))
|
| 32 |
+
|
| 33 |
+
# Estimated Salary
|
| 34 |
+
estimated_salary = st.sidebar.number_input("Estimated Salary", min_value=0, max_value=100000)
|
| 35 |
+
|
| 36 |
+
# Female
|
| 37 |
+
gender = st.sidebar.selectbox("Enter your gender", ("Male", "Female"))
|
| 38 |
+
country = st.sidebar.selectbox("Enter your Country", ("france", "Spain","germany"))
|
| 39 |
+
|
| 40 |
+
# Predict the customer's churn status
|
| 41 |
+
if st.sidebar.button("Predict"):
|
| 42 |
+
|
| 43 |
+
if gender=="Male":
|
| 44 |
+
female, male = 0,1
|
| 45 |
+
elif gender =="Female":
|
| 46 |
+
female, male = 1,0
|
| 47 |
+
|
| 48 |
+
if country == "france":
|
| 49 |
+
france, germany, spain = 1,0,0
|
| 50 |
+
elif country == "germany":
|
| 51 |
+
france, germany, spain = 0,1,0
|
| 52 |
+
else:
|
| 53 |
+
france, germany, spain = 0,0,1
|
| 54 |
+
|
| 55 |
+
features = [credit_score, age, tenure, balance, num_of_products, has_cr_card, is_active_member, estimated_salary, female, male, france, germany, spain]
|
| 56 |
+
prediction = model.predict([features])
|
| 57 |
+
|
| 58 |
+
# Display the prediction
|
| 59 |
+
st.write(f"The customer is predicted to churn: {prediction}")
|