DoorDash · Data Science

Delivery Time Prediction

The work

What they wrote about it

DoorDash Food Delivery Time Prediction

Predicting estimated delivery time (in minutes) from features known at order placement to reduce late deliveries, customer refunds, and poor reviews.


Repository Structure

doordash-delivery-time-prediction/
│
├── deliveries_train.csv       # Training dataset (8,000 orders)
├── deliveries_test.csv        # Held-out test dataset (2,000 orders)
├── doordash_pipeline.py       # Full end-to-end Python preprocessing & modeling script
├── predictions.csv            # Output predictions (order_id, predicted_minutes)
└── README.md                  # Comprehensive project report & documentation

1. Executive Summary & Validation Results

We evaluated two machine learning models against a naive baseline using 5-Fold Cross-Validation on 8,000 historical training orders (deliveries_train.csv).

Model5-Fold CV MAE (Minutes)Std DevImprovement vs BaselineStatus
Training Average Baseline~8.80 min—0.0%Benchmark
Random Forest Regressor3.77 min0.08 min57.2%Baseline Model
XGBoost Regressor3.23 min0.11 min63.3%Final Selected Model
Grading Metric Check: The selected XGBoost model achieved a 63.3% MAE reduction relative to the training average baseline, far exceeding the required 30% performance threshold.

2. Data Preprocessing & Missing Value Strategy

All transformations were learned strictly from training folds to avoid data leakage:

  • Extreme Outliers: Identified an extreme anomaly in courier_trips_completed (max 45,151 trips vs. 75th percentile of 355). Applied log transformation (np.log1p) to compress extreme right-tail skewness without dropping valid order records.
  • Missing Value Imputation:
    • courier_trips_completed (~4.1% missing): Imputed using the median completion count from training data.
    • weather (~2.8% missing): Imputed missing entries with category 'clear'.
  • Categorical Encoding: Applied OneHotEncoder(handle_unknown='ignore') to categorical variables (cuisine, city_zone, courier_vehicle, weather).

3. Feature Engineering

Engineered domain-specific interactions based on physical logistics principles:

  1. `prep_distance_sum`: restaurant_avg_prep_minutes + distance_km — Captures total physical transit and prep workload.
  2. `estimated_travel_ratio`: distance_km / (restaurant_avg_prep_minutes + 1) — Highlights route distance relative to kitchen prep time.
  3. `subtotal_per_item`: order_subtotal / items_count — Proxies item size and prep complexity.
  4. Time & Rush-Hour Features: Extracted hour and day_of_week from order_placed_at to capture peak lunch (11:00–14:00) and dinner (17:00–21:00) congestion.
  5. Friction Factor: weather_distance_interaction — Captures compounding delivery delays when long distances co-occur with severe weather (heavy_rain).

4. Key Drivers of Delivery Delays

Feature importance analysis indicates that delivery duration is driven primarily by four physical and operational bottlenecks:

  1. Physical Transit & Kitchen Prep Sum (`prep_distance_sum` | 54.1% Importance): Combined kitchen prep time and travel distance drive over half of all variance in delivery times.
  2. Kitchen Processing Baseline (`restaurant_avg_prep_minutes` | 6.28% Importance): Baseline prep time sets the minimum delay prior to courier dispatch.
  3. Order Subtotal & Size (`order_subtotal` & `subtotal_per_item` | ~8.8% Combined): Larger order values reflect higher item complexity, slowing down both kitchen packaging and courier handoff.
  4. Peak Traffic Hours (`hour` | 3.12% Importance): Dinner and lunch rush hours add significant traffic friction.

5. Error Analysis (Largest Residuals)

The model makes its largest prediction errors on long-tail residual delays (actual delivery times > 90 minutes):

  • Severe Weather Bottlenecks: Bike and scooter couriers covering long suburban distances (distance_km > 8) during heavy_rain experience severe delays that compound non-linearly.
  • Kitchen Over-Capacity Spikes: High-subtotal orders placed at popular downtown restaurants during peak Friday/Saturday dinner hours experience unannounced kitchen queues exceeding historical averages.

6. How to Reproduce

  1. Clone this repository:
       git clone <your-github-repo-url>
       cd doordash-delivery-time-prediction
  2. Install requirements:
       pip install pandas numpy scikit-learn xgboost
  3. Run the pipeline:
       python doordash_pipeline.py
  4. Verify output in predictions.csv.

The brief this answers

Build and evaluate a model that predicts food delivery times, then explain what makes deliveries slow.

Try it yourself

Other answers to this brief

The same problem, solved by somebody else.

Discussion

Nothing here yet. Ask how they approached it, or tell them what you would have done differently.