Business and operations
Machine learning for data-driven last-mile delivery optimization
In last-mile delivery, machine learning predicts travel times between stops, how long each drop-off takes and which sequence a driver will actually follow. A vehicle-routing solver then uses those estimates to build feasible routes and time windows.
How machine learning is used in last-mile delivery
Predicting travel times between stops
Travel-time models predict how long each leg of a route will take from the road network, time of day and recent traffic. Better leg times make planned routes and promised windows more realistic. Gradient-boosted trees and graph neural networks over road segments are used.
Real exampleGoogle Maps ETA prediction with graph neural networksThe paper presents a graph neural network that predicts travel times over the road network and is deployed in production at Google Maps.
Learning the sequence drivers actually follow
Experienced drivers often depart from the solver's route because of parking, building access and local knowledge. Models trained on historical driven routes learn those preferences so planned sequences match what happens on the road.
Real exampleAmazon Last Mile Routing Research ChallengeAmazon, supported by MIT's Center for Transportation and Logistics, released 9,184 historical routes and asked participants to develop machine learning methods that enhance optimisation-based routing.
Estimating delivery and pickup times
Courier event logs record when a task is accepted and finished, which lets a model predict the time to deliver each package. These estimates set customer time windows and feed dispatch decisions. Gradient-boosted trees and sequence models are typical.
Real exampleLaDe last-mile delivery dataset (Cainiao)LaDe is a public industry dataset of about 10.7 million packages from 21,000 couriers over six months, with task-accept and task-finish events, evaluated on three delivery tasks.
Learning routing heuristics
Instead of hand-designing a route construction rule, a neural network is trained to build routes and then judged on route length. This is research-led work, and learned heuristics are usually compared with established solvers.
Real exampleAttention, Learn to Solve Routing ProblemsKool, van Hoof and Welling train an attention-based model with reinforcement learning to construct solutions for travelling salesman and vehicle routing variants, with results close to specialised algorithms.
Can you learn machine learning for last-mile delivery?
Yes. Last-mile work combines regression for time estimates with classic vehicle-routing optimisation, so you need both sides. Learn Python and pandas, then statistics and regression, then time-series and spatial features, and study a routing solver alongside.
- Python and pandas for delivery logsTurn scan and GPS events into one row per stop with arrival, service and departure times.Learn it in Data Tools
- Regression and gradient boostingPredict leg and service times with linear models and gradient-boosted trees, and measure error in minutes against the average per area.Learn it in Machine Learning
- Optimisation and graphsLearn shortest paths, linear programming and the vehicle routing problem so you can see how time estimates enter a solver.
- Deep learning for sequences and graphsSequence and graph models are used for route prediction and travel time once tabular baselines are in place.Learn it in Deep Learning
Moving into machine learning for last-mile logistics
If you already work in the field
Logistics planners and dispatch analysts know depots, vehicle limits, time windows and why routes fail on the day. Add Python, regression and a routing solver such as OR-Tools. A realistic first move is to predict service time per stop from past scans and compare planned and actual route durations with and without it.
If you come from data science or ML
If you come from ML, learn vehicle routing, depot operations and how dispatch decisions are made each morning. Ride along or review driver feedback, because parking, access and customer availability explain much of the error a model sees.
Roles that do this workLogistics data scientistOperations research scientistRouting and dispatch analystTransportation analyst
Tools you will use
| Tool | What you use it for |
|---|---|
| OR-Tools | Solve vehicle-routing problems with time windows and capacities using your predicted times. |
| PyVRP | Solve capacitated and time-windowed routing problems with a fast open-source solver. |
| OSRM | Compute road travel times and distance matrices from OpenStreetMap data. |
| OSMnx | Download and analyse street networks to build features for delivery areas. |
| LightGBM | Train fast gradient-boosted models for stop-level travel and service times. |
Public data to practise on
- LaDe (Cainiao last-mile delivery dataset): Package pickup and delivery records with courier, area and timestamps; predict delivery times and courier routes.
- Amazon Last Mile Routing Research Challenge: Historical Amazon delivery routes with stop, package and travel-time data; learn the stop sequences drivers followed.
Your first project
Download LaDe-D, predict the time from task acceptance to delivery with LightGBM using courier, area and hour features, and compare it with the average duration per area using mean absolute error.
Common questions
Is route optimisation machine learning?
Classic route optimisation is operations research: solvers search for the best routes given distances, capacities and time windows. Machine learning usually supplies the inputs, such as travel and service times, and sometimes learns heuristics or driver preferences.
What data is needed for last-mile delivery models?
Stop locations, planned and actual sequences, scan timestamps, package counts and time windows, plus road network data such as OpenStreetMap. Weather and traffic history help for travel-time models.
What is the vehicle routing problem?
It asks how a fleet of vehicles should serve a set of customers at least cost while respecting limits such as capacity and time windows. It is hard to solve exactly at scale, so practical systems use heuristics and solvers.
Courses for these skills
- Practical Machine Learning in PythonCompare forecasting models under a temporal split.51 published lessons · more lessons in production
- Maths for Machine LearningUnderstand objectives, constraints and gradients.26 published lessons · all planned lessons open
- Deep Learning with PyTorchBuild neural approximation foundations.Syllabus available · lessons open as produced
- Python for AI and Machine LearningWrite repeatable functions for feature construction and evaluation.33 published lessons · all planned lessons open
- Data Tools: NumPy, pandas, Matplotlib and scikit-learnWork with dates, missing observations and lagged tables.23 published lessons · all planned lessons open
New to programming or maths? Start with Python, or follow the machine learning path in order. Published lessons are free to read; compare Free and Pro.