Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Send More Riders

peteowlett
February 02, 2016

Send More Riders

Predictive scheduling for an on demand delivery fleet

peteowlett

February 02, 2016
Tweet

More Decks by peteowlett

Other Decks in Technology

Transcript

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

    View Slide

  2. High quality food, delivered fast and
    on demand

    View Slide

  3. View Slide

  4. Life of an order

    View Slide

  5. Life of an order

    View Slide

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

    View Slide

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

    View Slide

  8. •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 …

    View Slide

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

    View Slide

  10. Before we dive
    in - a quick
    apology

    View Slide

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

    View Slide

  12. Forecasting Daily Volume

    View Slide

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

    View Slide

  14. Forecasting Daily Volume

    View Slide

  15. View Slide

  16. 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

    View Slide

  17. First Results

    View Slide

  18. Holidays (and Weather)
    Forecasting Daily Volume

    View Slide

  19. Improving the seasonal
    50%
    Improvement!

    View Slide

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

    View Slide

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

    View Slide

  22. 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]

    View Slide

  23. Forecasting Daily Volume

    View Slide

  24. 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

    View Slide

  25. 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

    View Slide

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

    View Slide

  27. Efficiency
    Orders per
    driver
    per hour
    Hour of Day

    View Slide

  28. Final Forecast

    View Slide

  29. Getting the forecast out into the real world

    View Slide

  30. Volumes to Shifts

    View Slide

  31. Deployment

    View Slide

  32. SUCCESS!!!

    View Slide

  33. 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

    View Slide

  34. Thanks!

    View Slide