chiichann commited on
Commit
5e451cb
·
verified ·
1 Parent(s): dfe582d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -20
app.py CHANGED
@@ -9,28 +9,27 @@ import seaborn as sns
9
  # App title
10
  st.title("🛍️ Customer Segmentation Tool")
11
 
12
- # About the App
13
- st.write("""
14
- This app uses unsupervised learning techniques to segment customers based on their purchasing behavior.
15
- The dataset is preloaded and contains online retail data.
16
- """)
 
17
 
18
- # How it Works section
19
- st.write("""
20
- ### How It Works:
21
- 1. **Load Customer Transaction Data**:
22
- - The app loads online retail data from an Excel file, including key information such as `Quantity`, `UnitPrice`, and `CustomerID`.
23
-
24
- 2. **Data Processing**:
25
- - It processes the data by calculating the total amount spent by each customer (`TotalSpent`), derived from multiplying `Quantity` and `UnitPrice`.
26
- - The data is then aggregated by `CustomerID` to summarize the total amount spent, the number of unique transactions, and the total quantity purchased.
27
 
28
- 3. **Apply K-Means Clustering**:
29
- - Using unsupervised learning, the app applies the K-Means clustering algorithm to segment the customers into distinct groups based on their purchasing behavior.
30
-
31
- 4. **Visualize the Customer Segments**:
32
- - A scatter plot is generated to visually display the customer segments, showing the `TotalSpent` versus the number of transactions (`NumTransactions`), with different clusters represented by different colors.
33
- """)
34
 
35
  # Load dataset
36
  file_path = "Online Retail.xlsx" # Updated file path
 
9
  # App title
10
  st.title("🛍️ Customer Segmentation Tool")
11
 
12
+ # About the App section with a toggle button
13
+ st.sidebar.header("About the App")
14
+ with st.sidebar.expander("Learn more about the app"):
15
+ st.write("""
16
+ This app uses unsupervised learning techniques to segment customers based on their purchasing behavior.
17
+ The dataset is preloaded from an Excel file containing online retail data.
18
 
19
+ ### How It Works:
20
+ 1. **Load customer transaction data**:
21
+ - The app loads customer transaction data, including key details like `Quantity`, `UnitPrice`, and `CustomerID`.
22
+
23
+ 2. **Process the data**:
24
+ - The data is processed by calculating the total amount spent (`TotalSpent`) for each customer. This is done by multiplying `Quantity` and `UnitPrice`.
25
+ - The information is then aggregated by `CustomerID` to summarize the total amount spent, the number of unique transactions, and the total quantity purchased by each customer.
 
 
26
 
27
+ 3. **Apply K-Means Clustering**:
28
+ - The app applies K-Means clustering to segment the customers into distinct groups based on their purchasing behavior, using the processed data.
29
+
30
+ 4. **Visualize the customer segments**:
31
+ - A scatter plot is created to visualize the customer segments, where customers are grouped based on the `TotalSpent` and the number of transactions (`NumTransactions`), with each cluster represented by different colors.
32
+ """)
33
 
34
  # Load dataset
35
  file_path = "Online Retail.xlsx" # Updated file path