KatInterview

Predicting Delivery Lateness Risk for a Food Delivery Platform

Machine LearningModel answer
HardModel answerMachine Learningml-system-designclassificationtemporal-data

Last updated

Design an ML system to forecast whether orders will arrive after their promised time, covering feature engineering, temporal validation, calibration, and production deployment.

You're building a machine learning system for a food delivery platform to predict whether orders will be delivered late. An order is considered late if it arrives after the estimated delivery time that was shown to the customer when they placed the order.

You have access to historical order data including merchant information, location details, order attributes, delivery logistics, and final outcomes.

Address the following:

  1. Target and data splitting: Define the prediction target precisely. Design a time-based train/validation/test strategy that prevents information leakage from future data. Specify concrete date ranges and explain your embargo periods.

  2. Feature engineering: Identify 10+ features that would be available at order placement and would have strong predictive signal. Consider merchant patterns, logistics capacity, geography, timing, and external factors.

  3. Leakage prevention: List 5+ sources of potential data leakage in this problem and explain how you would prevent each one.

  4. Evaluation and decisions: Choose appropriate metrics for both ranking quality and probability calibration. Define how you would set decision thresholds based on business costs, and estimate the potential financial impact.

  5. Production deployment: Outline a staged rollout plan from shadow mode through A/B testing. Describe how you would monitor model performance over time and handle drift and recalibration needs.

  6. Cold-start and seasonality: Explain how you would handle new merchants or markets with limited history, and how you would account for time-based patterns like holidays or day-of-week effects.

Your answer should demonstrate production ML thinking: temporal correctness, calibrated probabilities, business-driven decision making, and operational robustness.

Hints

Hint 1

Consider what information is truly known at order creation versus what becomes available later during fulfillment

Hint 2

The difference between your internal estimate and the customer-facing promise is often highly predictive

Hint 3

Random train/test splits will give you overly optimistic results - orders from the same time period should stay together

Hint 4

Calibration matters as much as discrimination when you're making cost-based decisions