--- 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.")