The interview question

Predict when a delivery will reach a customer, updating the estimate as the trip progresses.

Define the prediction timestamp, handle unfinished trips, and separate route estimates from customer promises.

01. Define several prediction problems

An estimate at checkout includes preparation, pickup, and travel. An estimate after pickup concerns a different remaining journey. Specify which stage the model serves and whether it returns an expected arrival time, a median, or a conservative promise.

Start with component baselines: historical preparation time by restaurant and time of day plus a route-based travel estimate. A learned residual model can correct systematic bias. This makes it easier to diagnose whether an error came from preparation or travel.

02. Construct time-consistent examples

Trip events
Live features
Arrival estimate

Create a training row at an explicit prediction event with features available then. The target is remaining time from that event to successful arrival. Do not include the eventual route, final trip duration, or a traffic measurement received afterward.

Completed trips alone may exclude the longest ongoing trips or cancellations. Define the population and treatment of censored outcomes instead of silently deleting inconvenient cases. Multiple rows from one trip are correlated; split by time and keep trip membership in mind when estimating uncertainty.

03. Serve updates with bounded work

A location stream updates trip state. A feature service supplies route progress and recent conditions; the model predicts remaining time; a policy smooths updates for display. Version the feature schema and expose prediction timestamp and freshness. Recompute on meaningful changes rather than on every GPS point.

If 100,000 active trips update every 30 seconds, the illustrative average is about 3,333 scoring requests per second. Batch compatible work where deadlines permit, and protect the route service with caches and per-trip coalescing. A burst after a reconnect requires capacity beyond the average.

04. Evaluate usefulness and fallback behavior

Measure absolute error by prediction stage, city, trip length, and unusual conditions. For a promised quantile, measure empirical coverage as well as interval width. A very wide promise can achieve coverage while being unhelpful. Track unstable estimate jumps and customer-visible lateness.

If live traffic is unavailable, return a historical route estimate with a freshness indicator and wider uncertainty. Follow-up: smoothing reduces visible jitter but can hide a real delay. Allow large evidence-backed changes through, and evaluate the displayed estimate rather than only raw model outputs.

Practice the follow-up

Self-review

What changes in your labels and features when prediction moves from checkout to the moment after pickup?

Connect this to probability calibration.

Sources & further reading

Forecasting: point forecast accuracy. The interview scenario, calculations, and proposed design choices are illustrative.

Continue your preparation

Choose a connected learning path or browse more ML system design questions. Read our editorial method and attribution policy.