A Machine Learning Model for Van Sales
Tags: machinelearning, vansales, sale, aws
Published: 2022-08-20 15:58:58

## Overview
Workers in offices and industrial estates outside of the major cities are often served by food trucks (or “Vans”) for their lunch and other refreshment needs. These food truck/van operators typically sell a mix of Sandwiches, Salads, Juices and other Chilled and Ambient Items. 

The Quantity of Products loaded at the beginning of the day are based on an estimate by the Operations Manager and the Van Operator’s acumen. These products are always ordered some days in advance. The order quantity is often a fine balance between the estimated demand for a given day and the desire to eliminate food wastage.

To estimate the order quantity, the Operations Manager or the Van operator utilise the following heuristics:

- The likely weather in the region in which their Vans operate.
  * Lower Temperature == Lower Sales
  * Higher Precipitation == Lower Sales

- Seasonality
  * Which Month of the year - Sales trend higher towards July, August
  * Which Week of the month - Week 1 is the best, trending lower towards Week 4
  * Which Day of the Week - Wed & Thurs is the best.

- Competitive Intensity
  * Additional Suppliers at the same Office Parks/Industrial Estates for similar products affect the Sales negatively.

Whilst these heuristics are well established the computation process is completely informal and van sales operators usually lack a system to ensure that order quantities are well reasoned and predictable.

We decided to create a suggested ordering system that would make the ordering process more predictable, reduce dependence on an individual’s acumen and automate load order quantity.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3agkfqxnssmeplrjl8z6.png)

This system would allow the user to enter a target date and then would generate a suggested order that can be downloaded and (changed if desired) then keyed into a Production Ordering System that a Van Sales operator might be using.

- The Suggested Order will contain the total quantities of all products that will be ordered and loaded into a Van.
- The Suggested Order quantity for a product will be the sum-total of all sales for that product across all 

## Solution Architecture
We created a ML model using AWS Forecast. To create the training dataset we used sales data for a Van Sales Operator running a fleet of 15 vans (a.k.a Routes) going back to 2010. We chose the top 200 products that this operator sold (to keep our dataset manageable) and collected the following information for each Product sold:
-	Date of sale
-	Route / Van it was sold on
-	Total Sales (QTY)

To get competitive intensity we asked the Van drivers and Sales Team Leaders to complete a survey asking them for each Month & Year going back to 2010 what the competition was like in their region, from the survey we prepared a dataset with the following structure:
- Columns
  * Van Numbers
- Each Row
  * Month & Year
  * Competitive Intensity ranked on a 1-3 scale -	1 being Low Competitive Intensity,	2 being Medium Intensity, 3 being High Intensity

- To obtain weather data we used the Met-Office Historical Data Series
[Link](https://www.metoffice.gov.uk/datapoint/product/historical-station-obs)
  * The Temperature, Precipitation and Sunshine Duration for the general geography of the Route a Van followed on the Date of the Sale.

Using this Training dataset AWS forecast created for us an ML model that predicted sales for a product given the:

- Temperature (Mean?)
- Precipitation
- Mins/Hrs of Sunshine
- Month (1-12)
- Week Number (1-4)
- Day Number (1-7)
- Competitive Intensity (1 – 3)

## Deploy the model in an online User Interface:
We created an online User Interface that can be used without access to AWS forecast but that interacts directly with the ML model.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oiruaovs3i0ybpwooi1o.png)
 
P90 refers to a forecast with a 90% confidence interval.
 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j2j41jh6090zonjvpd9b.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q3p94cyxrw5p8qwmpiyv.png) 

## Further Improvements (Future Phase)
A planned future improvement is to keep updating the model dynamically with actual sales thus ensuring a feedback loop that will improve the accuracy of the prediction.
This model is available on an MIT license for free use by the community – please contact the author to use this model.