Designing a Profitable Taxi Route Prediction Model

Machine Learning · Medium · Free problem

You are given historical taxi trip data including pickup/dropoff locations, timestamps, fares, tips, and trip durations.

  1. How would you design a model to predict the most profitable routes for a taxi driver throughout the day?
  1. Discuss your choice of target variable, feature engineering, modeling approach, and how you would evaluate the system.

Hints

  1. The target variable should be profit per hour, not profit per trip. Why does the denominator matter so much?
  2. Think about what features capture demand variation: time of day, location clusters, weather, and events all create predictable demand patterns.
  3. This is fundamentally a sequential decision problem. A greedy policy (pick the best next action) is a strong baseline, but reinforcement learning can capture multi-step value.

Worked Solution

How to Think About It: The core challenge is not just predicting fare amounts -- it is predicting profit per unit time. A $50 fare that takes 2 hours and burns

0 in fuel is worse than a
5 fare that takes 15 minutes. The driver's scarce resource is time, so the target variable must be a rate, not a total. The second challenge is that this is a sequential decision problem: after dropping off a passenger, the driver must decide where to go next, and that choice affects future opportunities.

Key Insight: The right target variable is profit per hour, not total profit per trip. This accounts for both trip duration and dead time between fares.

The Method:

Step 1: Define the target variable.

$\text{Profit per hour} = \frac{\text{fare} + \text{tip} - \text{fuel cost}}{\text{trip time} + \text{wait time for next fare}}$

The denominator is critical -- it includes the time spent waiting or cruising for the next passenger. Without this, you bias toward long airport runs that look profitable per-trip but waste time.

Step 2: Feature engineering.

Step 3: Modeling approach.

Use gradient boosted trees (XGBoost or LightGBM) for the prediction model. These handle non-linear interactions well (e.g., airport pickups are great at 5 PM but terrible at 2 AM) and are robust to mixed feature types.

Train on historical trip data with time-series cross-validation -- never train on future data. Use expanding-window validation: train on months 1-3, validate on month 4; train on 1-4, validate on 5; etc.

Step 4: Decision layer.

After predicting profit/hour for candidate actions (drive to location A, B, C, or wait in place), choose the action with the highest predicted rate. This is a greedy one-step-ahead policy. For better performance, use reinforcement learning (Q-learning or policy gradient) to optimize multi-step decisions -- but the greedy policy is a strong baseline.

Step 5: Evaluation.

Practical Considerations:

Answer: Build a gradient boosted model predicting profit per hour (including wait time in the denominator) using spatial, temporal, demand, and weather features. Evaluate with time-series backtesting on daily revenue. For multi-step optimization, layer a reinforcement learning policy on top of the point predictions.

Intuition

This problem tests whether you can frame a real-world optimization as a machine learning pipeline. The most common mistake is treating it as a simple regression (predict fare from features) without thinking about what the driver actually needs to optimize. A driver does not care about the fare of a single trip in isolation -- they care about their earning rate across the entire shift. This means the target variable, the feature set, and the evaluation metric all need to reflect the time dimension.

The deeper lesson is about the gap between prediction and decision-making. A great fare prediction model is useless if it does not tell the driver what to do next. The decision layer -- whether greedy or RL-based -- is where the value is created. In quant finance, this is analogous to the difference between a return forecast and a portfolio optimizer: the forecast is necessary but not sufficient.

Open the full interactive solver →