Predictive Analytics – an application in Milk Supply Forecasting

We keep hearing the buzzwords predictive analytics and data science far too often these days. What do they mean? Are these actually as cool as they sound? Or are they just marketing fads?

Predictive analytics refers to the prediction of future events and trends based on the statistical analysis of current and past data.

It can be considered a subset of data science, which in general, refers to any quantitative and qualitative method of solving problems through data inference and exploration. While the definitions as such might not be awe inspiring, what actually makes these concepts really important is how they can drive important decisions on diverse topics ranging from supply chain planning and marketing to weather forecast and economic predictions. And, more than just being buzzwords, these actually carry a lot of opportunities for businesses, academia and common man in terms of day-to-day decisions and future plans.

Definitions and hype! How about a specific example of application of these concepts?

The following is a brief look at predictive analytics being used in a real business scenario related to dairy industry.


Dairy companies receive their milk supply from a number of dairy farms located across different regions. The amount of milk produced by the cows, each day, depends on a variety of factors including season, rainfall, humidity, and so on. It is critical for the dairy companies to accurately forecast the amount of milk to be expected for future periods so that accurate plans can be created to optimally allocate milk amongst the production lines for different dairy products. In turn, instances of wastage and shortfall can be reduced. Further, it is also important to predict the composition of milk, because it is the actual fat and protein content of the milk that drives the quantity of milk products that can be produced from it.


Predictive modelling techniques can be used to solve this business problem by forecasting the expected milk supply based on the actual historical data available. Further, the entire solution can be packaged into a user-friendly app that can run the predictive algorithms in the background to create forecasts, with but the click of a few buttons. An app that provides such a solution is described here. It showcases the great features offered by R (a powerful & very widely used statistical programming language & software package), SAP HANA (SAP’s in memory database offering) and SAPUI5 (SAP UI for HTML 5) to create extremely accurate forecasts based on predictive modelling techniques. While this app can be generalized to different kinds of forecasts used in different industries, this specific example is customized to predict the milk supply expected from participating farms for a dairy company.


The app creates accurate forecasts for the milk supply (both at total milk and also at fat, protein composition level) expected from different regions, for future periods. The forecasts are predictively modelled based on the actual historical data. While creating the forecast, the user can determine the extent of past data to be considered and the future period for which the forecast should cover. The app also includes some handy additional features including, but not limited to a workspace where the user can perform in depth analysis of the forecasts (e.g. comparing forecasts with actual data from same periods of multiple years from the past) and if needed, override parts of the forecasts manually, instant validation of the accuracy levels of new forecasts by allowing the comparison of actuals and forecasts for a user selected period immediately before the actual forecast horizon, email / text notifications for scheduled forecast runs, and Excel download of the detailed forecasts.


Promising accuracy levels of 95-98% have been achieved using our beta version. This is entirely due to the appropriate use of the forecast package for short term (7 days) and long term (365 days) predictions.


The app interfaces to an R server, for fast, accurate forecasting. The forecasting is done with the R forecast package, using methods that automatically fit an ARIMA (Auto Regressive Integrated Moving Average) model. The app sits atop SAP HANA and owes, in part, it’s speed to HANA’s column store. The actual data used by the app is loaded to the HANA database from the relevant source systems using data transformations. The user-friendly interface of the app is implemented using SAP UI5.


Now that the basic objective of creating accurate forecasts has been achieved, there are multiple opportunities to enhance this piece of software. The future capabilities may include

  • an enhanced forecasting algorithm that also takes into account other relevant information like weather data obtained from organizations such as the Bureau of Meteorology,
  • additional functionalities to automatically create the optimal production plans based on the forecasts created

Described above is a simple example that is just an indication of the capabilities of predictive analytics. By crossing the concepts of data science with great technologies like R and HANA, simple yet extremely powerful tools can be created to enable the right decisions. It is safe to assume that we will see businesses investing considerably in such apps in the near future.

Sandra Cutic