Slide 1

Slide 1 text

Send More Riders! Predictive scheduling for an on demand delivery fleet @PeterOwlett

Slide 2

Slide 2 text

High quality food, delivered fast and on demand

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Life of an order

Slide 5

Slide 5 text

Life of an order

Slide 6

Slide 6 text

Utilisation % Hour of Day (Colour = Day of Week)

Slide 7

Slide 7 text

We need enough drivers to deliver on time, but not so many we lose money

Slide 8

Slide 8 text

•Restaurants take longer than expected to make food •Items get missed - we have to go back and get them •Drivers become unavailable (flat tyre etc) •Customers hard to find It gets harder …

Slide 9

Slide 9 text

Exam question How many drivers should we schedule for the next two weeks in each part of London over 15 minute blocks?

Slide 10

Slide 10 text

Before we dive in - a quick apology

Slide 11

Slide 11 text

Lets formulate! Where • O is orders • d is date • z is zone

Slide 12

Slide 12 text

Forecasting Daily Volume

Slide 13

Slide 13 text

This book is awesome And Free!!! - https://www.otexts.org/fpp

Slide 14

Slide 14 text

Forecasting Daily Volume

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

Statsmodels supports this out of the box Forecasting Daily Volume # Decompose the raw time series decomposition = sm.tsa.seasonal_decompose(data.values, freq=7) # Extract individual components all_trend = decomposition.trend all_seasonal = decomposition.seasonal all_resid = decomposition.resid

Slide 17

Slide 17 text

First Results

Slide 18

Slide 18 text

Holidays (and Weather) Forecasting Daily Volume

Slide 19

Slide 19 text

Improving the seasonal 50% Improvement!

Slide 20

Slide 20 text

•Vary the training range •Train on np.log(series) and transform back Signal in the noise? Looks Seasonal Looks Seasonal Random Noise

Slide 21

Slide 21 text

Because we can chart each series, we can reason about how to improve our model

Slide 22

Slide 22 text

Forecast each component Forecasting Daily Volume # Forecast Trend lm_lin = LinearRegression().fit(dates, trend_vals) forecast_trend = lm_lin.predict(forecast_window) # Forecast Seasonal seasonal_pattern = np.tile(base_seasonal_pattern, math.ceil(days_to_forecast / 7.0)) forecast_seasonal = seasonal_pattern[0: days_to_forecast]

Slide 23

Slide 23 text

Forecasting Daily Volume

Slide 24

Slide 24 text

Where • O is orders • D is demand • E is efficiency • z is zone • d is date • w is weekday • t is time of day Converting Daily Orders to Driver Hours

Slide 25

Slide 25 text

Zero to One Scale - neat trick Estimating Demand Curves scaled_series = df_mean_curves.order_volume / df_mean_curves.groupby(['zone', ‘day_of_week’])\ .transform(np.sum).order_volume

Slide 26

Slide 26 text

Estimating Demand Curves Ratio of daily orders per unit time Hour of Day

Slide 27

Slide 27 text

Efficiency Orders per driver per hour Hour of Day

Slide 28

Slide 28 text

Final Forecast

Slide 29

Slide 29 text

Getting the forecast out into the real world

Slide 30

Slide 30 text

Volumes to Shifts

Slide 31

Slide 31 text

Deployment

Slide 32

Slide 32 text

SUCCESS!!!

Slide 33

Slide 33 text

1. While not as powerful as R, Statsmodels does give you core time series tools 2. Seasonal decomposition is very meaningful to human beings 3. By using all python, we were able to ship quickly Stuff we learned

Slide 34

Slide 34 text

Thanks!