Perform probabilistic time series forecast from a deep learning model and perform what-if analysis on the forecast.
We shall be doing a probabilistic time-series forecast of the sales for a salad manufacturer and then use Atoti for inventory management and find the optimum number of refrigerators to store the salad products.
What is probabilistic time series forecasting and why do we need it?
The concept of probabilistic forecasting was developed for addressing a very wide variety of issues such as commodity stock price forecasting or weather forecasting. The rationale behind a probabilistic approach or a quantile-based approach is quite simple: the less likely an event is to occur, it would be placed in the more extreme quantile. So the most likely prediction would be placed in the 50th quartile scenario.
The typical mean or median based methods tend to ignore the extreme situations and derive towards the “usual” scenario. Hence, in the domain of supply chain and food processing, these methods are not very effective at preventing both stock-outs and dead inventory. Quantile based forecasts approach can enable us to directly look at the scenario of interest, say avoiding stock-outs, and strive to provide a precise answer to this very problem of ignoring the extremes.
What is GluonTS?
Here, we have used GluonTS to do probabilistic time series forecasting. GluonTS is a python toolkit for probabilistic time series modeling, built around Apache MXNet. It has been built by the Amazon Web Services — Labs. GlounTS leverages the truly open-source deep learning framework suited for flexible research prototyping and production at Apache MXNet.
GluonTS provides utilities for loading and iterating over time-series datasets. It provides classical models like ARIMA to forecast time series and also pre-trained state of the art Deep Learning models ready to be fine-tuned, and quickly experiment with different solutions. Also, it allows you to assemble pre-defined stacks in order to build your own Deep Learning architecture and train your model from scratch.
Most traditional time-series predictions predict a single ‘most-likely’ value for the future. Hence, in order to solve this issue, here GluonTS is used for making probabilistic forecasts and then the values corresponding to a mist of given quantiles are picked from the forecast.
With GluonTS you can also:
- Train and evaluate any of the built-in models on your own data, and quickly come up with a solution for your time-series tasks.
- Use the provided abstractions and building blocks to create custom time series models, and rapidly benchmark them against baseline algorithms.
Interpreting the results: The Atoti magic!
In this use case, we have information about composition, selling price, volume, and sales data for various salad products. And the objective is to optimize the storage capacity for the future.
The traditional approach would be to make a median-based time series forecasting for the sales and hence predict the storage capacity and the related cost.
But thanks to Atoti and GlounTS, we can now make a prediction for various quantiles of the sales forecast and let the business choose how aggressive or reserved they want to be with the inventory acquisition and hence the manufacturing capabilities.
So once we get the quantile-based sale prediction outputs we put them in a vector and merge them to the existing sales store in Atoti. This is then used to perform cube slicing and scenario creation for the additional storage capacity, associated cost incurred, etc.
We create the scenarios for the sales prediction for the 0.99 and 0.01 quantiles. For the newly created scenarios, we calculate the available storage for three randomly chosen salad products.
The availability of three salads products for various forecast quantiles.
Observation: Here we can see that for many salads, we need additional storage (i.e. the available storage is negative) only in the case of 0.99 quantile of sales. For some products such as the Caesar salad, we do not need the additional space even for the 0.99 quantile of sale.
How to interpret these volumes?
For the various prediction scenarios, since we have the number of products to be sold and given the storage capacity and the product volume, we can calculate the total additional volume required. This can be simply converted into the number of refrigerators with an underlying assumption that the storage capacity of a refrigerator is 200 Litres.
From cold storage capacity to additional potential margin:
Although this additional cold storage capacity can bring in some potential revenues, it also has an operational cost. So with how much increase in the cold storage the net margin is maximum? Is it even profitable to augment the cold storage capacity? Thanks to Atoti, we can answer all these questions. Not only that, we can find the breakdown of the total costs and the total revenue for the scenarios with different numbers of refrigerators.
Here, we assume that the total daily operational cost of a refrigerator is 5 euros per day. And though there is no limit on the number of scenarios, for the sake of clarity we will compare the scenarios with 10, 15, 20, 25, and 40 refrigerators.
Q1 — How much of the total additional potential revenue can we actually realize in these scenarios.
Here we can see, as we keep on increasing the cold storage capacity, there is an increase in the additional potential revenue which can be realized. With 40 refrigerators, we can realize almost the full potential revenue.
Q2 — But how much would it cost to the business?
Intuitively, the total cost keeps on increasing as the cold storage capacity increases. The production and ingredients cost increase proportionally to the number of products being sold on that day while the additional storage cost being constant depending on the number of refrigerators.
Here is a comparison of the total revenue and the total cost for the cases with a varying cold storage capacity.
While having 40 additional refrigerators may materialize the full potential revenue, the return of investment ($3,730.90) is lesser than the rest of the scenarios. We can see that maximum revenue does not equate to the maximum margin in this case.
Q3 — So more potential revenue or less total cost, which scenario is the best?
We calculate the margin for the different scenarios and hence the one with the maximum positive margin will be our best scenario.
Margin can be defined as the difference between the potential additional revenue realized and the total cost for that scenario.
Hence, it can be concluded that in the scenario with 0.99 quantile of sales, we get an optimum additional margin by acquiring 15 additional refrigerators. So we should not be acquiring more than 15 refrigerators at the given daily operating price and the capacity of the refrigerators.
For the detailed source code and many other such interesting use cases, do check out the Atoti notebook gallery on GitHub. And here is the article detailing the whole notebook and along with the data schema.