KatInterview

Build a Travel Time Prediction Service for Ride Applications

Machine LearningModel answer
MediumModel answerMachine Learningml-system-designproduction-mlregression

Last updated

Design a machine learning system that forecasts journey duration for ride-hailing trips, addressing data collection, feature design, model choice, and deployment.

Problem

You're building a travel time forecasting system for a ride-hailing platform. The system needs to predict how long a trip will take from the passenger's current location to their destination, measured in minutes.

Your design should address:

  1. Data Collection: What information would you gather, both from past rides and in real-time, to build and operate this predictor?

  2. Feature Design: Identify at least four distinct features that capture patterns related to time, location, and external conditions like weather or road congestion.

  3. Model Architecture: Select an appropriate modeling approach. Explain whether you'd use linear regression, tree-based methods, or neural networks, and why.

  4. Performance Measurement: Define how you'd assess prediction quality. How would you account for unusual delays caused by incidents or accidents?

  5. Production Deployment: Outline how you'd meet low-latency requirements when handling millions of simultaneous prediction requests.

Context

  • Historical GPS trajectories, road network topology, and weather data are available
  • Predictions must complete within 100 milliseconds
  • Your design should cover the data flow, modeling strategy, and quality metrics

Deliverable

Present a technical design covering data infrastructure, the machine learning approach, and evaluation methodology.

Hints

Hint 1

Think about separating the routing problem from the prediction problem—what if you use a baseline path calculator and have ML correct its mistakes?

Hint 2

Consider how traffic patterns vary by time of day, day of week, and location—which encoding techniques preserve these cyclic relationships?

Hint 3

Production latency matters: can you pre-compute or cache parts of the prediction to stay under 100ms at high query volumes?