Update app.py
Browse files
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.
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 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 |
-
|
| 30 |
-
|
| 31 |
-
4. **Visualize the
|
| 32 |
-
|
| 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
|