Aufgabe 5

Nachfrageprognose & Personalplanung

Bestellhistorie, Wetterdaten und lokale Events analysieren, um Nachfrage vorherzusagen und einen optimierten Küchenbesetzungsplan zu erstellen.

Aufgabe 1 Aufgabe 2 Aufgabe 3 Aufgabe 4 Aufgabe 5 Aufgabe 6
1

Die Herausforderung verstehen

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.

Goal: Given historical order data plus external factors (weather, holidays, sports events), predict how many orders Roberto's will receive per hour and recommend how many kitchen staff to schedule.
2

Datenquellen erkunden

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
Note: Data files will be provided by your instructor. If the directory is empty, ask for the dataset package.
3

Bestellmuster analysieren

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())
"
Key patterns to find:
  • Which days have the highest/lowest order volume?
  • What are the peak hours (lunch vs. dinner rush)?
  • Are there seasonal trends?
  • How does weather affect orders?
4

Nachfrageprognose-Modell erstellen

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
Useful features: day of week, hour, temperature, rain probability, is_holiday, is_school_break, sports_event_nearby, previous_week_orders.
5

Personalempfehlungen generieren

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
Consider: What happens when your prediction is wrong? Build in a buffer (e.g., +1 staff during uncertain periods). Over-staffing costs money, under-staffing loses customers.
6

Ergebnisse präsentieren

Prepare a presentation covering:

  • Which factors most influence order volume? (feature importance)
  • Visualization of predicted vs. actual demand
  • Your generated weekly staff schedule with justifications
  • Cost analysis: what would over/under-staffing cost Roberto?
  • How could this system integrate with the API in production?
Success criteria:
  • Model predicts demand with reasonable accuracy (MAPE < 25%)
  • Staff schedule covers all opening hours
  • Visualizations clearly show demand patterns
  • External factors (weather, events) improve predictions
  • You can explain the trade-off between over- and under-staffing