In this article
Before you start
This page is one worked problem in the machine learning (ML) system design guide.
Why interviewers ask this
An ETA question looks like plain regression, so it separates people who recite a model from people who think about the product. The number is shown to a customer who plans around it, so its errors have different costs: arriving late annoys more than arriving early. The model also feeds other systems, since dispatch and pricing read the same estimate.
A weak answer picks a model and minimises squared error, which gives the same weight to early and late misses. A strong answer splits the trip into stages, keeps the routing engine as a baseline, chooses a loss from the cost of lateness, names real-time features (a feature is an input the model reads) and the latency limit, and evaluates with the late rate, the share of orders that arrive after the shown ETA. The prompt appears in system design rounds for ride-hailing, delivery and logistics roles, often as "estimate delivery time" or "design a real-time ETA system".
ETA prediction from first principles
- ETA prediction
- ETA prediction is the task of estimating the time remaining until a trip, pickup or delivery completes, from the request, the route and live conditions, so the estimate can be shown to a customer and used by other systems.
- Residual model
- A residual model is a model trained to predict the difference between a baseline estimate and what actually happened, so that the baseline's strengths are kept and only its systematic error is learned.
- Pinball loss
- Pinball loss is a training and scoring loss for quantile prediction (a quantile is a percentile written as a fraction: the 0.67 quantile is the 67th percentile) that charges an error more on one side than the other, so the best prediction is a chosen percentile of the outcomes rather than their average.
In plain words
Think of a friend who tells you when they will arrive. They know the roads, so their guess for the drive is good. They forget the time spent getting ready. You learn to add a correction. It is bigger at rush hour. You also learn to ask for a later time when meeting a client. Waiting is cheaper than being waited for. An ETA model learns the correction and the safe side to err on. The analogy breaks here: a model serves millions of such guesses and must answer in a few milliseconds.
In one precise sentence: an ETA system splits a trip into stages, takes a routing estimate as the base, learns the residual from live features with a loss that matches the cost of lateness, and checks the result by how often it is late.
Step 1: Split the trip into stages
The input is the request: origin, destination, time and, for delivery, the merchant. The output is a list of stages with their own uncertainty. A ride has a pickup leg and a trip leg. A delivery has preparation at the merchant, a wait for a courier to arrive and the transit to the customer. Each stage is driven by different things: the merchant's speed, the number of couriers nearby, the road.
Ask first what the ETA is for: Uber notes that different business uses need different point estimates.
Splitting matters because the stages fail differently and a single number hides which one is wrong. Variance is a measure of how spread out the times are. In the toy run below, preparation accounts for 45.3% of the variance of delivery time, transit 31.2% and pickup wait 16.7%.1 The other 6.7% is shared, because wait and transit both rise at peak hour.1 A routing engine only sees the transit. What you now know: the largest uncertainty may be outside the map.
Step 2: Start from the routing estimate and learn the residual
The routing engine is the service that computes a route and its travel time from a road graph. Keep it as the base and learn the residual. Uber describes this as using machine learning to predict the residual between the routing engine ETA and real-world observed outcomes, and says updating the post-processing model is generally easier than refactoring the routing engine (Uber Engineering, February 2022).
The residual model is a good deal because the routing engine already encodes the road network, which would take a lot of data to relearn. In the toy run, the routing estimate alone is 16.9 minutes short on average off-peak and 25.4 minutes short at peak, because it ignores preparation, waiting and congestion.1 A learned correction by distance, peak hour and merchant class removes most of that. What you now know: the model learns the gap, not the whole answer.
Step 3: Pick the loss from the cost of being late
Squared error is each miss multiplied by itself, so big misses count most. Training with it aims at the average and ignores which side of the truth a miss falls on. Take an illustrative cost: a minute late costs 2 units and a minute early costs 1. Now raise the shown ETA by one minute. Every order that would have been late saves 2 units, and every order that would have been early costs 1 more. Keep raising it while the late share times 2 beats the early share times 1. Stop when the late share is one in three, which is 2 / (2 + 1) ≈ 0.67, the 67th percentile.1
Pinball loss trains for exactly that. scikit-learn documents it for scoring a chosen quantile, and its example trains a quantile model with it (scikit-learn 1.9.1 documentation, read October 2026). Uber's DeepETA uses a parameterised loss, the asymmetric Huber loss, which resists outliers and lets the team set the cost of underprediction against overprediction, and notes that some uses call for a specific quantile (Uber Engineering, February 2022).
The toy run checks the argument by sweeping the percentile. The cost per order is 9.27, 8.63, 8.49, 8.53, 9.23 and 11.75 units at the 50th, 60th, 67th, 70th, 80th and 90th percentiles, so the minimum sits at the 67th.1 Against the average, the late share falls from 43.6% to 33.2%, at the price of a higher mean absolute error, the average size of the miss in minutes.1 What you now know: the loss encodes the product.
Text description of the diagram
- A minute late costs 2 units and a minute early costs 1 in the toy run.
- The cost per order is lowest, 8.49 units, at the 67th percentile.
Step 4: Add real-time features and meet the latency limit
The features come in three groups: spatial and temporal inputs such as origin, destination and the time of the request; real-time conditions such as traffic; and the type of request. Uber lists these, and says the model must return an ETA within a few milliseconds at most and that its post-processing model is the highest-queries-per-second model at the company (Uber Engineering, February 2022).
That limit shapes the design. Precompute slow features, such as a merchant's recent median preparation time, in a feature store and read them with one batched call. Keep per-area traffic aggregates as streaming state. Keep the model small enough, or cache by coarse location, so a response fits the budget. A graph neural network, a model that passes information along the road graph, is another route. Negative ETA outcomes are the paper's term for poor ETA results. Google reports that the network significantly reduced them compared to the previous production baseline, by 40% or more in cities such as Sydney (Derrow-Pinion et al., 2021). What you now know: freshness and speed are design constraints.
Step-by-step description
- Routing estimate plus a learned correction.
- Precomputed and streaming inputs.
- The actual duration, after completion.
- Retrain, then test on a hold-out.
- The routing engine gives the base estimate and the residual model adds a learned correction.
- The residual model reads precomputed and streaming features and must answer in a few milliseconds.
- The label is the actual duration, known only after the order completes.
- A small share of orders kept on a reference policy measures the feedback loop.
Step 5: Evaluate by late rate, and plan for cold start and feedback
The model learns from labels, and the label is the actual duration, which is known only when the order completes. Cancelled orders have no label, so count them separately rather than treating them as zero-minute trips. Evaluate with the metrics the loss implies. Report mean absolute error, and also the late rate, which is the share of orders that arrive after the shown ETA, with the average minutes late. Slice by stage, hour, city and merchant, because a good average can hide a bad city.
Two traps remain. A cold start is a new area or merchant with no history, so fall back to a coarser group, such as the city, until data accumulates. A feedback loop is an effect where the shown ETA changes behaviour, for example by changing which orders are accepted or how couriers are dispatched, so later data no longer matches the data the model was trained on. A small share of orders kept on a reference policy measures the feedback loop. What you now know: judge the model by the error that costs money.
Step-by-step description
- Preparation, wait and transit.
- Routing estimate plus a learned gap.
- A quantile from the cost ratio.
- Traffic, supply, merchant speed.
- Late rate by stage and city.
- A delivery splits into preparation, courier wait and transit.
- The routing engine estimate is the base and a model learns the residual.
- The loss is a quantile chosen from the cost of being late.
- Evaluate by late rate, the share of orders that arrive after the shown ETA.
Knowing it is half the job. Saying it is the other half.
Interview Clozo is an AI interview copilot for real interview rounds: it hears the question and puts a strong answer on your screen, and you say it in your own words. See the features or how it works.
Start Free Trial →Worked example
Everything here is a toy simulation with illustrative inputs; the script is saved with the page.1 It simulates 100,000 training and 50,000 test deliveries. Each delivery has a preparation time that depends on the merchant class, a pickup wait, and a transit time that depends on distance and on whether it is peak hour. The routing estimate is the free-flow transit time. The learned model is deliberately simple: the correction is the residual's mean, median or 67th percentile within each of 36 groups of distance, peak flag and merchant class, learned on the training set.1
| Shown ETA | Mean absolute error (min) | Late (%) | Minutes late when late | Cost per order |
|---|---|---|---|---|
| Routing engine only | 19.88 | 99.97 | 19.89 | 39.77 |
| Routing plus mean residual | 5.87 | 43.6 | 6.73 | 8.81 |
| Routing plus median residual | 5.80 | 49.9 | 6.95 | 9.27 |
| Routing plus 67th-percentile residual | 6.36 | 33.2 | 6.42 | 8.49 |
The cost column charges 2 units a minute for lateness and 1 for earliness. The routing engine alone is early or on time for 14 of the 50,000 test orders, so it is late for 99.97%.1 The median has the best mean absolute error, which is the right result: absolute error is minimised at the median, and a business cost that is not symmetric is minimised somewhere else. The stage split from Step 1 is in the second diagram.
Text description of the diagram
- Preparation accounts for 45.3% of the variance of delivery time in the toy run.
- Transit accounts for 31.2% and pickup wait for 16.7%; 6.7% is shared because wait and transit both rise at peak hour.
Trade-offs and edge cases
An ETA system trades accuracy against the cost of being wrong in each direction and against the latency it can afford.
- A conservative ETA is a product choice. Aiming at a high percentile lowers lateness but makes every promise longer; test the effect on conversion, not only on error.
- Stage models or one model. Separate models per stage are easy to debug; one model over all stages is simpler to serve. When stage predictions are added together, their errors add up too, and at peak the wait and transit errors move together: 6.7% of the toy variance is shared.1
- Spatial generalisation. A model trained in one city can fail in another with different traffic. Use city-level features and a coarse fallback, and see distribution shift.
- Freshness. A stale traffic feature can mislead at peak, when conditions change fastest; alert on feature age, as in the feature store walkthrough.
- Downstream use. Dispatch and pricing read the same ETA, so a bias in it moves marketplace decisions; version it and test changes in an experiment.
- Anomalies. Road closures and storms break history; watch the error series for sudden shifts (anomaly detection in time series).
For the serving side see machine learning operations (MLOps), and for a neighbouring design with a latency budget see real-time fraud detection.
How to answer it in an interview
Design a system that estimates delivery time for an order.
First I would ask what the ETA is for: a customer promise, dispatch or the fare. Then I would split the order into preparation, courier wait and transit. The routing engine gives the transit estimate, and I would train a residual model on top, using merchant history, live traffic, courier supply and time of day. Because lateness costs more than earliness, I would train with a quantile or asymmetric loss and tune the percentile from that ratio. Slow features come from a feature store, live ones from streaming state, and the response must fit a few milliseconds. I would evaluate late rate by stage and city, and handle new merchants with a coarser fallback.
The spoken structure: stages, base plus residual, loss from cost, features and latency, evaluation.
Common mistakes
- "I would use the map's ETA." (wrong) It covers only the transit leg and ignores preparation and waiting. (right) "I would use it as the base and learn the residual."
- "I would minimise mean squared error." (wrong) That aims at the average, which ignores the cost ratio. (right) "I would pick a quantile from the cost of lateness."
- "I would report one overall error." (wrong) A good average hides a bad city or a slow merchant class. (right) "I would slice by stage, hour, city and merchant, and report late rate."
- "A new merchant just gets a prediction." (wrong) There is no history to predict from. (right) "I would back off to a coarser group until data builds up."
Follow-up questions
Design an ETA prediction system for a ride-hailing app?
Split into pickup and trip legs, start from the routing engine and learn the residual from live traffic, time and supply features. Choose the loss from the cost of lateness and serve inside a few milliseconds.
Build a model to estimate delivery time?
Model preparation, courier wait and transit separately or as one residual over the routing estimate, with merchant history as one of the features. In the toy run preparation caused 45.3% of the variance.1
Design a real-time ETA system that accounts for physical delays, restaurant prep times and courier availability?
Feed live merchant prep times, courier counts near the merchant and traffic as streaming features with a freshness check, and recompute the estimate as stages complete.
How would you design a delivery ETA system that works across cities with very different traffic patterns?
Use city and area features, a hierarchy of groups to fall back on, and per-city monitoring, with a freshness check on live inputs as in the feature store walkthrough. Retrain per region if error differs. A graph-based road model, as Google describes, is another way to carry spatial structure.
Why not just use the map ETA?
It covers only the travel leg under typical conditions. In the toy run it was 16.9 minutes short off-peak and 25.4 at peak, and it was late for 99.97% of orders, all but 14 of 50,000.1
What if a late minute costs four times an early one?
The target moves to 4 / (4 + 1) = 0.8, the 80th percentile. In the toy run the 0.8 quantile has the lowest cost under that ratio, 11.66 units, against 12.76 at the 0.67 quantile.1 A neighbouring design with the same latency pressure is real-time fraud detection.
- Split the trip into stages; the largest uncertainty may be outside the map.
- Keep the routing estimate as the base and learn the residual.
- Choose the loss from the cost of lateness: a 2-to-1 cost ratio points at the 67th percentile.
- Real-time features and a few-millisecond limit shape the serving design.
- Evaluate by late rate, sliced by stage and city, and plan for cold start.
Sources
- DeepETA: How Uber Predicts Arrival Times Using Deep Learning — Uber Engineering, 10 Feb 2022
- ETA Prediction with Graph Neural Networks in Google Maps (arXiv 2108.11482) — arXiv (Derrow-Pinion et al.), 25 Aug 2021
- Metrics and scoring: pinball loss (scikit-learn 1.9.1 documentation; undated page, read 2026-10-24) — scikit-learn, 24 Oct 2026