4. Data split

Train on the past, test on the future

The 36,416 usable orders are sorted by when they were placed, then cut at 70% and 85%. The model learns from the oldest orders and is tested on the newest, the same way the app will use it.

Why not a random split?

A random split mixes orders from the same days into training and testing. The model could then learn something about a busy evening from orders in that same evening and look better than it really is, because it has effectively seen the future. Splitting by time removes that shortcut: every test order was placed after every training order.

The cut points never split orders placed at the same minute, so the shares are as close to 70/15/15 as the timestamps allow.

PartitionOrdersShareFirst orderLast order
Training25,48970%2022-02-11 08:102022-03-25 19:30
Validation5,46415%2022-03-25 19:352022-03-31 21:50
Test5,46315%2022-03-31 21:552022-04-07 00:00

Orders per day, by partition

Each column is one calendar day. Empty days are dates with no orders in the dataset.

  • Training
  • Validation
  • Test
Feb 11Feb 18Feb 25Mar 4Mar 11Mar 18Mar 25Apr 1

Training covers about six weeks. Validation and test each cover about one week at the end.

Show the numbers
DateTrainingValidationTest
2022-02-1170000
2022-02-1254700
2022-02-1368200
2022-02-1454000
2022-02-1567400
2022-02-1655300
2022-02-1768900
2022-02-1854800
2022-02-191000
2022-03-0198600
2022-03-0275600
2022-03-031,01600
2022-03-0474100
2022-03-051,01600
2022-03-0675100
2022-03-0799600
2022-03-0873800
2022-03-091,01700
2022-03-1075500
2022-03-111,00200
2022-03-1274400
2022-03-131,02100
2022-03-1472400
2022-03-151,04200
2022-03-1674200
2022-03-1798600
2022-03-1874600
2022-03-191,01100
2022-03-2074100
2022-03-211,00300
2022-03-221200
2022-03-2372500
2022-03-241,01100
2022-03-252644810
2022-03-2601,0260
2022-03-2707230
2022-03-2809950
2022-03-2907390
2022-03-3009980
2022-03-310502225
2022-04-01001,003
2022-04-0200746
2022-04-03001,032
2022-04-0400712
2022-04-05001,015
2022-04-0600721
2022-04-07009

What each partition is for

Training
25,489
The models learn from these orders. Every fitted step, including the median used to fill gaps and the one-hot categories, comes from here only.
Validation
5,464
Used to compare the models and choose each one's settings. The model with the lowest error here is the one the app selects.
Test
5,463
Checked once, at the end, after refitting on training and validation orders. These scores are the honest estimate of how the app will do.

Before the split, 7,884 orders without a road distance, 86 outside the app's distance limits and 1,198 without an order time were left out.