amariayudha commited on
Commit
a028909
Β·
verified Β·
1 Parent(s): 99fd4aa

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +82 -23
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
- # Set the title of the app
8
- st.title("Customer Churn Analysis App")
 
 
 
 
 
 
 
 
 
 
 
9
 
10
- # Create a sidebar for navigation
11
- st.sidebar.title("Navigation")
12
- page = st.sidebar.radio("Go to", ["Home", "Predict Churn", "EDA"])
13
 
14
- # Define the home page
15
- if page == "Home":
16
- st.write("## Welcome to the Customer Churn Analysis App")
17
- st.write("""
18
- This application allows you to:
19
- - Predict customer churn based on input data.
20
- - Perform exploratory data analysis (EDA) on customer churn data.
21
- Use the sidebar to navigate between the pages.
22
- """)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
- # Navigate to the Predict Churn page
25
- elif page == "Predict Churn":
26
- predict.run()
 
 
 
 
27
 
28
- # Navigate to the EDA page
29
- elif page == "EDA":
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()