Bestellhistorie, Wetterdaten und lokale Events analysieren, um Nachfrage vorherzusagen und einen optimierten Küchenbesetzungsplan zu erstellen.
Roberto's Pizzeria needs to plan staff schedules a week in advance. Too many cooks on a quiet Monday wastes money; too few on a busy Friday evening means long wait times and unhappy customers. Your task is to build a data-driven staffing recommendation system.
You have access to several data files that will drive your predictions:
# Fetch historical order data from the API curl -s http://localhost:8080/menu | python3 -m json.tool # Weather data for the region cat /data/exercise4/weather.json | python3 -m json.tool | head -30 # Calendar with holidays and school breaks cat /data/exercise4/calendar.json | python3 -m json.tool # Local sports events (football matches drive pizza orders!) cat /data/exercise4/sports_events.json | python3 -m json.tool # Menu item preparation times cat /data/exercise4/menu.json | python3 -m json.tool
Start by understanding the baseline demand patterns from historical order data:
# Load and explore order history python3 -c " import pandas as pd import json # Load order history orders = pd.read_json('/data/exercise4/order_history.json') print(f'Total orders: {len(orders)}') print(f'Date range: {orders.date.min()} to {orders.date.max()}') # Orders by day of week orders['dow'] = pd.to_datetime(orders['date']).dt.day_name() print(orders.groupby('dow')['order_count'].mean()) # Peak hours orders['hour'] = pd.to_datetime(orders['timestamp']).dt.hour print(orders.groupby('hour')['order_count'].sum()) "
Combine order history with external data to predict future demand:
# Feature engineering python3 build_features.py \ --orders /data/exercise4/order_history.json \ --weather /data/exercise4/weather.json \ --calendar /data/exercise4/calendar.json \ --sports /data/exercise4/sports_events.json \ --output features.csv # Train prediction model python3 train_model.py \ --features features.csv \ --model random_forest \ --output demand_model.pkl # Predict next week's demand python3 predict.py \ --model demand_model.pkl \ --start-date 2026-03-23 \ --days 7 \ --output predictions.json
Convert demand predictions into actionable staff schedules:
# Staffing rules # - 1 cook can handle ~8 orders/hour # - Minimum 2 staff at all times # - Maximum 6 staff in the kitchen # - Shifts are 4 or 8 hours python3 generate_schedule.py \ --predictions predictions.json \ --cook-capacity 8 \ --min-staff 2 \ --max-staff 6 \ --output weekly_schedule.json # Visualize the schedule python3 visualize.py \ --schedule weekly_schedule.json \ --output schedule_chart.png
Prepare a presentation covering: