KatInterview

Design an ML System to Forecast Shipment Arrival Time

Machine LearningModel answer
HardModel answerMachine Learningml-system-designtime-to-eventfeature-engineering

Last updated

Design an end-to-end ML system that predicts when a parcel will arrive, covering target definition, features, leakage prevention, uncertainty, and production monitoring.

Shipment Arrival Time Forecasting

An e-commerce platform wants to show customers a reliable delivery estimate at every stage of their order's journey — from checkout through final drop-off. You have access to historical shipment data including order timestamps, origin and destination locations, carrier and service tier selections, logistics scan events, route-level weather forecasts, and holiday calendars.

Design a machine learning system that predicts how long a shipment will take to arrive. Your answer should address:

  1. Target definition and prediction timing — What exactly are you predicting, and at which points in the shipment lifecycle do you generate a prediction?
  2. Feature engineering and model selection — Which signals matter most, and what model family fits this problem well?
  3. Missing or delayed data and leakage prevention — Scan events arrive late and in batches. How do you prevent future information from contaminating training?
  4. Offline and online evaluation — How do you measure model quality before and after deployment?
  5. Prediction intervals and product integration — How do you produce calibrated uncertainty estimates, and how should the product surface them?
  6. Production monitoring and retraining — How do you detect when the model degrades and keep it fresh?

There is no single correct architecture. The interviewer is looking for clear reasoning about trade-offs, awareness of the failure modes specific to logistics forecasting, and a design that would actually work under real operational conditions.

Hints

Hint 1

Think carefully about what information is actually available at each prediction stage — checkout, label creation, first scan, and in-transit updates each have different feature sets. Define one prediction problem per stage rather than trying to handle all stages with the same snapshot.

Hint 2

The most common source of leakage in this problem is not using point-in-time correct feature computation. Any aggregate — such as a carrier's historical median transit time or a warehouse's handling time — must be computed as of the prediction timestamp, not as of today. Also, always use ingestion time when building scan-based features, never event time.

Hint 3

Uncertainty is a first-class deliverable, not a nice-to-have. Think about how a p10/p50/p90 prediction translates into a product experience differently from a single point estimate, and how you would verify that your p90 interval actually covers 90% of outcomes in practice.