Skip to content
Data Management

What predictions do we get from using Machine Learning algorithms?

Machine Learning (3/3) – Prediction Results

After the first post introducing Machine Learning algorithms, and following the second one covering the time series study and the algorithm chosen for use, we arrive at the final post in this series.

We will start with a chart to refresh your memory on the data we had available, then move on to look at the prediction made by R, and finally, we will use a B.I. tool to graphically represent actual consumption versus the predictions made, as well as the error of the predictions compared to actual consumption.

Why is forecasting important?

As described in the previous post, it’s important to anticipate future sales in order to manage resources within the organization and reduce operating costs.

The data used for the forecast, as shown in the following image, corresponds to sales from June 2014 to January 2017.

A 10-month forecast was made, covering February through November.

Data for the months between February and November is available to compare the forecast with actual sales.

Forecasts Using the Arima Algorithm in RStudio

After applying the Arima algorithm, we obtain the following results in R:

Represented graphically in R, we get the following:

The gray line represents actual past consumption. The blue line marks the forecast made, and the shaded areas show the confidence intervals: the blue shaded area represents the 80% confidence interval, while the gray shaded area represents the 95% confidence interval.

The confidence interval indicates how much reality may differ from the forecast. For example, in the case of the 95% interval, it represents a range within which there is a 95% chance that consumption for that month will fall.

At first glance, we can see that sales will drop significantly in August 2017, while the surrounding months will see strong sales of this product. This isn’t surprising at all—looking at previous years, we see that consumption is always very low in August and very high in the neighboring months. We can also see that there will be a drop in consumption in March, consistent with previous years, as a sharp decline can be observed in the third month of every year.

Drawing conclusions from the forecast alone is certainly useful, but it would be far better if we could compare the forecast with actual consumption and check how accurate the results are. Below is a chart representing this scenario:

In blue, we have previous consumption. In red, we have actual consumption between February and October 2017, and finally, the yellow bars represent the forecasts made by Arima.

As we can see, our forecast closely matches the actual sales data.

Forecast Quality

To measure how good a forecast is compared to actual results, the following formula is used, known as the Mean Percentage Error (MPE): where AC is actual consumption and PC is the forecasted consumption.

Similarly, the Mean Absolute Percentage Error (MAPE) can be calculated using the following formula. In this case, MPE = -5.30% and MAPE = 5.30%. This means we are looking at a highly accurate forecast.

Goals Achieved by Using Machine Learning Algorithms

This brings us to the conclusion of this series of posts, whose goals were:

1.- Understanding Machine Learning algorithms.

2.- Choosing the right algorithm for our data and objectives.

3.- Properly carrying out the forecast.

4.- Obtaining and graphically representing the results.

These goals allow us to forecast sales for a given product and thus adjust a company’s resources according to needs that may arise, thanks to the ability to anticipate the future with a forecast that very accurately represents reality.

Leave a Reply

Your email address will not be published. Required fields are marked *