Basak Tamer commited on
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# π½οΈ Waiter Tips Data Visualization & Analysis
|
| 2 |
|
|
|
|
|
|
|
| 3 |
### π Live Demo
|
| 4 |
[Link to your Hugging Face Space here]
|
| 5 |
|
|
@@ -9,23 +21,67 @@
|
|
| 9 |
**Aim:** To perform an Exploratory Data Analysis (EDA) on restaurant transaction data to identify the key factors that influence tipping behavior. The goal is to uncover patterns and correlations between the demographic profile of the customers and the gratuity they leave.
|
| 10 |
|
| 11 |
**Target:**
|
| 12 |
-
* **Customer Profiling:**
|
| 13 |
-
* **Temporal Analysis:** Identify which
|
| 14 |
* **Correlation Mapping:** Analyze the mathematical relationship between `total_bill` and `tip`.
|
| 15 |
-
* **Data Visualization:**
|
| 16 |
|
| 17 |
---
|
| 18 |
|
| 19 |
-
## π Key Metrics & Insights
|
| 20 |
* **Core Algorithm:** Bivariate & Multivariate Statistical EDA.
|
| 21 |
-
* **Key Metric:** **Tip Percentage (Tip %)**
|
| 22 |
-
* **Business Insight:**
|
| 23 |
|
| 24 |
---
|
| 25 |
|
| 26 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
pip install pandas numpy matplotlib seaborn plotly statsmodels streamlit
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Waiter Tips Analysis Dashboard
|
| 3 |
+
emoji: π½οΈ
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
# π½οΈ Waiter Tips Data Visualization & Analysis
|
| 12 |
|
| 13 |
+
This project explores restaurant transaction data to identify the key factors that influence tipping behavior. By transitioning from static EDA to an interactive Streamlit dashboard, this project demonstrates how data-driven insights can inform business decisions in the hospitality industry.
|
| 14 |
+
|
| 15 |
### π Live Demo
|
| 16 |
[Link to your Hugging Face Space here]
|
| 17 |
|
|
|
|
| 21 |
**Aim:** To perform an Exploratory Data Analysis (EDA) on restaurant transaction data to identify the key factors that influence tipping behavior. The goal is to uncover patterns and correlations between the demographic profile of the customers and the gratuity they leave.
|
| 22 |
|
| 23 |
**Target:**
|
| 24 |
+
* **Customer Profiling:** Determine if variables like gender or smoker status show a significant difference in tip amounts.
|
| 25 |
+
* **Temporal Analysis:** Identify which day of the week and which time result in the highest average tips.
|
| 26 |
* **Correlation Mapping:** Analyze the mathematical relationship between `total_bill` and `tip`.
|
| 27 |
+
* **Data Visualization:** Use advanced plots (Box, Violin, Sunburst, and 3D Scatter).
|
| 28 |
|
| 29 |
---
|
| 30 |
|
| 31 |
+
## π Key Metrics & Insights (Excel Summary)
|
| 32 |
* **Core Algorithm:** Bivariate & Multivariate Statistical EDA.
|
| 33 |
+
* **Key Metric:** **Tip Percentage (Tip %)**.
|
| 34 |
+
* **Business Insight:** Identifying "Peak Gratuity" windows helps restaurant managers schedule staff during high-earning shifts.
|
| 35 |
|
| 36 |
---
|
| 37 |
|
| 38 |
+
## π» Python Code (`app.py`)
|
| 39 |
+
This is the full source code used to generate the interactive dashboard:
|
| 40 |
+
|
| 41 |
+
```python
|
| 42 |
+
import streamlit as st
|
| 43 |
+
import pandas as pd
|
| 44 |
+
import plotly.express as px
|
| 45 |
+
import seaborn as sns
|
| 46 |
+
|
| 47 |
+
# 1. Page Configuration
|
| 48 |
+
st.set_page_config(page_title="Waiter Tips Dashboard", page_icon="π½οΈ", layout="wide")
|
| 49 |
+
|
| 50 |
+
# 2. Loading the Dataset
|
| 51 |
+
@st.cache_data
|
| 52 |
+
def load_data():
|
| 53 |
+
try:
|
| 54 |
+
df = pd.read_csv("waitertips.csv")
|
| 55 |
+
except FileNotFoundError:
|
| 56 |
+
df = sns.load_dataset('tips')
|
| 57 |
+
df['tip_pct'] = (df['tip'] / df['total_bill']) * 100
|
| 58 |
+
return df
|
| 59 |
+
|
| 60 |
+
df = load_data()
|
| 61 |
+
|
| 62 |
+
# 3. Sidebar
|
| 63 |
+
st.sidebar.title("Project Details")
|
| 64 |
+
st.sidebar.markdown("**Aim:** Identify factors influencing tipping.")
|
| 65 |
+
|
| 66 |
+
# 4. Main Header & Metrics
|
| 67 |
+
st.title("π½οΈ Waiter Tips Data Visualization")
|
| 68 |
+
col1, col2, col3 = st.columns(3)
|
| 69 |
+
col1.metric("Avg. Bill", f"${df['total_bill'].mean():.2f}")
|
| 70 |
+
col2.metric("Avg. Tip", f"${df['tip'].mean():.2f}")
|
| 71 |
+
col3.metric("Avg. Tip %", f"{df['tip_pct'].mean():.2f}%")
|
| 72 |
+
|
| 73 |
+
# 5. Interactive Visualization
|
| 74 |
+
st.subheader("π Interactive Tip Correlation")
|
| 75 |
+
fig_scatter = px.scatter(df, x="total_bill", y="tip", color="sex", size="size", trendline="ols")
|
| 76 |
+
st.plotly_chart(fig_scatter, use_container_width=True)
|
| 77 |
+
|
| 78 |
+
# 6. Advanced Charts
|
| 79 |
+
col_a, col_b = st.columns(2)
|
| 80 |
+
with col_a:
|
| 81 |
+
st.plotly_chart(px.sunburst(df, path=['day', 'time', 'sex'], values='tip'), use_container_width=True)
|
| 82 |
+
with col_b:
|
| 83 |
+
st.plotly_chart(px.violin(df, x="sex", y="tip", color="sex", box=True), use_container_width=True)
|
| 84 |
|
| 85 |
+
st.markdown("---")
|
| 86 |
+
st.subheader("π Conclusion")
|
| 87 |
+
st.info("Tipping behavior follows specific patterns that can be modeled for staffing optimization.")
|
|
|