File size: 3,235 Bytes
fda5522
c546369
fda5522
 
 
 
 
 
 
 
8c1763f
 
fda5522
 
8c1763f
 
 
 
 
 
 
 
 
fda5522
 
8c1763f
fda5522
8c1763f
 
 
fda5522
8c1763f
fda5522
 
8c1763f
 
 
fda5522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8c1763f
fda5522
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
title: Waiter Tips Data Visualization
emoji: 🍽️
colorFrom: blue
colorTo: green
sdk: streamlit
app_file: app.py
pinned: false
---

# 🍽️ Waiter Tips Data Visualization & Analysis

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.

### πŸš€ Live Demo
[Link to your Hugging Face Space here]

---

## πŸ“Œ Project Overview
**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.

**Target:**
* **Customer Profiling:** Determine if variables like gender or smoker status show a significant difference in tip amounts.
* **Temporal Analysis:** Identify which day of the week and which time result in the highest average tips.
* **Correlation Mapping:** Analyze the mathematical relationship between `total_bill` and `tip`.
* **Data Visualization:** Use advanced plots (Box, Violin, Sunburst, and 3D Scatter).

---

## πŸ“Š Key Metrics & Insights (Excel Summary)
* **Core Algorithm:** Bivariate & Multivariate Statistical EDA.
* **Key Metric:** **Tip Percentage (Tip %)**.
* **Business Insight:** Identifying "Peak Gratuity" windows helps restaurant managers schedule staff during high-earning shifts.

---

## πŸ’» Python Code (`app.py`)
This is the full source code used to generate the interactive dashboard:

```python
import streamlit as st
import pandas as pd
import plotly.express as px
import seaborn as sns

# 1. Page Configuration
st.set_page_config(page_title="Waiter Tips Dashboard", page_icon="🍽️", layout="wide")

# 2. Loading the Dataset
@st.cache_data
def load_data():
    try:
        df = pd.read_csv("waitertips.csv")
    except FileNotFoundError:
        df = sns.load_dataset('tips')
    df['tip_pct'] = (df['tip'] / df['total_bill']) * 100
    return df

df = load_data()

# 3. Sidebar
st.sidebar.title("Project Details")
st.sidebar.markdown("**Aim:** Identify factors influencing tipping.")

# 4. Main Header & Metrics
st.title("🍽️ Waiter Tips Data Visualization")
col1, col2, col3 = st.columns(3)
col1.metric("Avg. Bill", f"${df['total_bill'].mean():.2f}")
col2.metric("Avg. Tip", f"${df['tip'].mean():.2f}")
col3.metric("Avg. Tip %", f"{df['tip_pct'].mean():.2f}%")

# 5. Interactive Visualization
st.subheader("πŸ“Š Interactive Tip Correlation")
fig_scatter = px.scatter(df, x="total_bill", y="tip", color="sex", size="size", trendline="ols")
st.plotly_chart(fig_scatter, use_container_width=True)

# 6. Advanced Charts
col_a, col_b = st.columns(2)
with col_a:
    st.plotly_chart(px.sunburst(df, path=['day', 'time', 'sex'], values='tip'), use_container_width=True)
with col_b:
    st.plotly_chart(px.violin(df, x="sex", y="tip", color="sex", box=True), use_container_width=True)

st.markdown("---")
st.subheader("πŸ“ˆ Conclusion")
st.info("Tipping behavior follows specific patterns that can be modeled for staffing optimization.")