Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,89 @@
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
-
# Import the other scripts
|
| 4 |
-
import predict
|
| 5 |
import eda
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
st.sidebar.
|
| 12 |
-
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
eda.run()
|
|
|
|
| 1 |
+
# Import necessary libraries
|
| 2 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
| 3 |
import eda
|
| 4 |
+
import predict
|
| 5 |
+
|
| 6 |
+
# Set up the Streamlit page configuration
|
| 7 |
+
st.set_page_config(
|
| 8 |
+
page_title="Customer Churn Predictor",
|
| 9 |
+
page_icon="π",
|
| 10 |
+
layout="wide",
|
| 11 |
+
initial_sidebar_state="expanded"
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
def main():
|
| 15 |
+
# Navigation sidebar
|
| 16 |
+
st.sidebar.title("π§ Navigation")
|
| 17 |
+
page = st.sidebar.radio("Go to", ["π Home", "π EDA", "π Prediction"])
|
| 18 |
|
| 19 |
+
if page == "π Home":
|
| 20 |
+
# Sidebar content for Home page
|
| 21 |
+
st.sidebar.markdown("---")
|
| 22 |
+
st.sidebar.subheader("π About the Model")
|
| 23 |
+
recall = 0.89 # You may want to update this value based on your model's performance
|
| 24 |
+
st.sidebar.write("π― Model Recall:")
|
| 25 |
+
st.sidebar.progress(recall)
|
| 26 |
+
st.sidebar.write(f"{recall:.2%}")
|
| 27 |
+
st.sidebar.write("**π€ What is Recall?**")
|
| 28 |
+
st.sidebar.write("Recall measures how well our model identifies customers who are likely to churn.")
|
| 29 |
+
st.sidebar.write("**π‘ What does this mean?**")
|
| 30 |
+
st.sidebar.write("Out of all the customers who are likely to churn, our model correctly identifies 89% of them.")
|
| 31 |
+
st.sidebar.write("This helps us catch most cases, *reducing the chance of missing someone who needs attention*")
|
| 32 |
|
| 33 |
+
st.sidebar.markdown("---")
|
| 34 |
+
st.sidebar.subheader("π Fun Fact")
|
| 35 |
+
st.sidebar.info("It costs 5-25 times more to acquire a new customer than it does to retain an existing one.")
|
| 36 |
|
| 37 |
+
# Main content for Home page
|
| 38 |
+
st.title("π Welcome to Customer Churn Prediction Tool")
|
| 39 |
+
st.write("""
|
| 40 |
+
This application provides functionalities for Exploratory Data Analysis and
|
| 41 |
+
Prediction regarding customer churn risk. Use the navigation pane on the left to
|
| 42 |
+
select the module you wish to utilize.
|
| 43 |
+
""")
|
| 44 |
+
|
| 45 |
+
# Display image
|
| 46 |
+
col1, col2, col3 = st.columns([1,2,1])
|
| 47 |
+
with col2:
|
| 48 |
+
st.image("predictix.jpg", caption="Customer Churn Prediction", use_column_width=True)
|
| 49 |
+
|
| 50 |
+
st.markdown("---")
|
| 51 |
+
|
| 52 |
+
# Dataset information
|
| 53 |
+
st.write("#### π Dataset")
|
| 54 |
+
st.info("""
|
| 55 |
+
The dataset contains customer information including tenure, contract type, payment method,
|
| 56 |
+
monthly charges, total charges, and feedback. It's used to predict customer churn.
|
| 57 |
+
""")
|
| 58 |
+
|
| 59 |
+
# Problem Statement
|
| 60 |
+
st.write("#### β οΈ Problem Statement")
|
| 61 |
+
st.warning("""
|
| 62 |
+
Customer churn is a significant challenge for businesses, leading to revenue loss and increased
|
| 63 |
+
acquisition costs. Early identification of customers likely to churn is crucial for implementing
|
| 64 |
+
effective retention strategies. As a data scientist, your task is to develop a machine learning
|
| 65 |
+
model that can predict customer churn based on historical data and customer behavior patterns.
|
| 66 |
+
|
| 67 |
+
The goal is to develop a model with high recall to identify potential churners, allowing the
|
| 68 |
+
business to take proactive measures to retain these customers.
|
| 69 |
+
""")
|
| 70 |
+
|
| 71 |
+
# Project Objective
|
| 72 |
+
st.write("#### π― Objective")
|
| 73 |
+
st.success("""
|
| 74 |
+
This project aims to create a classification model to predict customer churn by evaluating
|
| 75 |
+
various algorithms. Model performance will be primarily assessed using Recall to measure
|
| 76 |
+
effectiveness in identifying potential churners, minimizing the risk of missing customers
|
| 77 |
+
who are likely to leave.
|
| 78 |
+
""")
|
| 79 |
|
| 80 |
+
elif page == "π EDA":
|
| 81 |
+
# Run the EDA module
|
| 82 |
+
eda.run()
|
| 83 |
+
|
| 84 |
+
elif page == "π Prediction":
|
| 85 |
+
# Run the Prediction module
|
| 86 |
+
predict.run()
|
| 87 |
|
| 88 |
+
if __name__ == "__main__":
|
| 89 |
+
main()
|
|
|