# A Sensor Data-Driven Decision Support System for Liquefied Petroleum Gas Suppliers
## 7 Case Study
### Medium-Term Prediction Example  
As was stated in Section 5, the short-term prediction model results can be aggregated to perform the forecasts of total gas capacity in a given (longer) period. Therefore, in this experiment, the task was defined as the prediction of the total demand for gas in a three-month period for a distribution station serving 749 customers. The measurements creating the data set were collected for a period from 1 January 2016 to 31 October 2018. They consisted of the daily gas level values for each customer location and hourly values of outside temperature measured at the selected weather station representative of the whole region. The proposed approach predicted daily LPG consumption for each tank in a data set, and the final results were summed up to a predicted gas demand between 1 January and 31 March 2018. The prediction was performed by means of an extended temperature-based model discussed in the previous section. It generated forecasts on the basis of climate-like temperature values calculated for each day in a year. The presented solution used the mean temperature value, the mean minimum temperature value, and the mean maximum temperature value on each day of the three previous years. Additionally, the feature vector was extended by the date-based attributes: the number of the day of the year, the number \begin{table}
\begin{tabular}{l c c c c c c} \hline \hline  & **Min.** & **1 st Qu.** & **Median** & **Mean** & **3 rd Qu.** & **Max.** \\ \hline Temperature based & 0.018 & 0.031 & 0.050 & 0.083 & 0.108 & 0.267 \\ Trivial last & 0.028 & 0.052 & 0.107 & 0.159 & 0.268 & 0.518 \\ Mean & 0.022 & 0.043 & 0.085 & 0.123 & 0.205 & 0.385 \\ Median & 0.024 & 0.044 & 0.085 & 0.122 & 0.207 & 0.367 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Short-term prediction error (RMSE) of gas consumption (m\({}^{3}\))—analysis of 19 tanks, 7-day prediction horizon. of the day of the month, the number of the day of the week, the number of the week in the year, the number of the month in the year, the number of the quarter in the year. Similar to the short-term prediction, the gradient boosting approach and its implementation included in the gradient boosting machines (gbm) R package were applied to the presented task [40, 41]. Again, the model was limited to 100 decision trees, and the other parameters of the method were set to default values. In cases where it was not possible to generate the model due to a lack of sufficient training (historical) data, the predicted consumption values were calculated as the mean consumption values in the week preceding the prediction period. The results of the proposed model are presented in Table 4. The approach was evaluated taking into consideration a relative error (relative to the actual value of consumption):  
\[E_{rel}=\frac{1}{T}\Sigma_{t=1}^{T}\frac{\hat{y}_{t}-y_{t}}{y_{t}} \tag{2}\]  
and a mean absolute error (MAE) calculated in liters:  
\[E_{mae}=\frac{1}{T}\Sigma_{t=1}^{T}|\hat{y}_{t}-y_{t}|, \tag{3}\]  
where \(T\) is the time of analysis in days corresponding to the number of examples, \(\hat{y}_{t}\) is a predicted consumption value on day \(t\), and \(y_{t}\) is an actual consumption value on day \(t\). The results of the proposed method referred to a trivial approach, which was calculated as the average gas consumption for a given tank on a given day in the last two years. Figure 9 presents the medium-term prediction on a monthly basis, in which the daily values were aggregated to monthly ones. The data series denoted as actual represents the actual gas consumption of all 749 consumers. The prediction1 series shows the forecast value for the model being trained on the data from 1 January 2016 to 31 December 2017. The predictor2 series shows the forecast value for the period from November 2018 to January 2019; in this case, the model was trained on all available data until October 2018 inclusive  
The results presented in Table 4 show that the proposed approach performed significantly better in the defined task.