# Electrical Load Forecast by Means of LSTM: The Impact of Data Quality

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Methods

#### 2.1. LSTM Forecasting Method

**Forget gate**The first gate, also called “forget gate” (Equation (1), where ${W}_{f}$ and ${b}_{f}$ are the weights and biases associates with the forget gate and $[\xb7,\xb7]$ is a simple vector concatenation) tells which information of the cell state ${C}_{t-1}$ should be retained or forgotten:$${f}_{t}=\sigma ({W}_{f}\xb7[{h}_{t-1},{x}_{t}]+{b}_{f})$$**Input gate**The input gate, on the other hand, decides which new information should be stored in the cell state for later use. It provides the following two operations:$${i}_{t}=\sigma ({W}_{i}\xb7[{h}_{t-1},{x}_{t}]+{b}_{i})$$$${\tilde{C}}_{t}=tanh({W}_{C}\xb7[{h}_{t-1},{x}_{t}]+{b}_{C})$$**Cell state**The new cell state, to be used in the next steps, can hence be computed as:$${C}_{t}={f}_{t}\ast {C}_{t-1}+{i}_{t}\ast {\tilde{C}}_{t}$$**Output gate**Once the cell state has been updated, an output (${h}_{t}$), dependent on the current input ${x}_{t}$ and on previous information, must be produced. In the output gate, the following operations are computed:$${o}_{t}=\sigma ({W}_{o}\xb7[{h}_{t-1},{x}_{t}]+{b}_{o})$$$${h}_{t}={o}_{t}\times tanh\left({C}_{t}\right)$$

#### 2.2. Outliers Detection

## 3. Error Metrics

- the Normalized Mean Absolute Error $NMAE$:$$NMAE=\frac{{\sum}_{t=1}^{N}\left|{e}_{t}\right|}{N\xb7{P}_{n}}\xb7100,$$
- the Normalized Root Mean Square Error $nRMSE$ is based on the maximum power output $\left({P}_{n}\right)$:$$nRMSE=\frac{1}{{P}_{n}}\xb7\sqrt{\frac{{\sum}_{t=1}^{N}{|{e}_{t}|}^{2}}{N}}\xb7100$$
- the Nash–Sutcliffe Efficiency Index ${E}_{f}$, was firstly introduced in [30] in a very different context such as hydrology. Its implications were later discussed in many articles such as [31]. Its definition is the following:$${E}_{f}=1-\frac{{\sum}_{i=1}^{N}{({P}_{f,i}-{P}_{m,i})}^{2}}{{\sum}_{i=1}^{N}{({P}_{m,i}-{\overline{P}}_{m})}^{2}}$$

## 4. Case Study

- date time column (yyyy-MM-dd HH:mm), with quarter-hour time step;
- electrical load measurements;
- sensor fault message (not mandatory).

#### 4.1. Dataset Cleaning

**No cleaning performed**: the full dataset is provided in the input to the LSTM model. The obtained results can be considered as a benchmark to evaluate the effectiveness of the following approaches. The forecast was performed on 34,368 samples because the first days of the year 2018 were provided as input as historical measurements;**Removal of holidays**. This case represents a cleaning procedure that can be implemented on the data looking and analyzing them manually. In fact, when dealing with industrial electrical load, no assumption can be made a priori regarding the plant operating status throughout the year. In this particular case, the plant shut down followed the Italian national holidays (e.g., Christmas and Easter) and other periods had to be removed as well showing the same trend (e.g., part of July and August);**Removal of the outliers through the Generalized ESD**. This methodology, whose implementation is further explained in the following section, is able to perform the dataset cleaning without any prior knowledge on the status of the plant and its scheduling activity. Furthermore, no information regarding any error occurred in the system is needed here;**Error removal**(information provided by the plant manager and data communication error): the case is representative of a full knowledge scenario, very unlikely to occur in real cases, where comprehensive information regarding the time series data are given such as unavailability, error caused in the data transmission, etc.

#### 4.2. Generalized ESD Application

#### 4.3. Dataset Aggregation and LSTM Architecture

## 5. Results and Discussion

## 6. Conclusions

## Author Contributions

## Funding

## Conflicts of Interest

## References

- Paoletti, S.; Casini, M.; Giannitrapani, A.; Facchini, A.; Garulli, A.; Vicino, A. Load forecasting for active distribution networks. In Proceedings of the IEEE PES Innovative Smart Grid Technologies Conference Europe, Manchester, UK, 5–7 December 2011; pp. 1–6. [Google Scholar] [CrossRef]
- Pasetti, M.; Rinaldi, S.; Manerba, D. A virtual power plant architecture for the demand-side management of smart prosumers. Appl. Sci.
**2018**, 8, 432. [Google Scholar] [CrossRef] [Green Version] - Taylor, J.W. Triple seasonal methods for short-term electricity demand forecasting. Eur. J. Oper. Res.
**2010**, 204, 139–152. [Google Scholar] [CrossRef] [Green Version] - Dordonnat, V.; Koopman, S.J.; Ooms, M.; Dessertaine, A.; Collet, J. An hourly periodic state space model for modelling French national electricity load. Int. J. Forecast.
**2008**, 24, 566–587. [Google Scholar] [CrossRef] [Green Version] - Nowicka-Zagrajek, J.; Weron, R. Modeling electricity loads in California: ARMA models with hyperbolic noise. Signal Process.
**2002**, 82, 1903–1915. [Google Scholar] [CrossRef] [Green Version] - Das, U.K.; Tey, K.S.; Seyedmahmoudian, M.; Mekhilef, S.; Idris, M.Y.I.; Van Deventer, W.; Horan, B.; Stojcevski, A. Forecasting of photovoltaic power generation and model optimization: A review. Renew. Sustain. Energy Rev.
**2018**, 81, 912–928. [Google Scholar] [CrossRef] - Muzaffar, S.; Afshari, A. Short-term load forecasts using LSTM networks. Energy Procedia
**2019**, 158, 2922–2927. [Google Scholar] [CrossRef] - Ding, N.; Benoit, C.; Foggia, G.; Besanger, Y.; Wurtz, F. Neural network-based model design for short-term load forecast in distribution systems. IEEE Trans. Power Syst.
**2016**, 31, 72–81. [Google Scholar] [CrossRef] - Hochreiter, S. Recurrent neural net learning and vanishing gradient. Int. J. Uncertainity Fuzziness Knowl. Based Syst.
**1998**, 6, 8. [Google Scholar] - Rosner, B. Percentage points for a generalized esd many-outlier procedure. Technometrics
**1983**, 25, 165–172. [Google Scholar] [CrossRef] - Nespoli, A.; Ogliari, E.; Pretto, S.; Gavazzeni, M.; Vigani, S.; Paccanelli, F. Data quality analysis in day-ahead load forecast by means of LSTM. In Proceedings of the 2020 IEEE International Conference on Environment and Electrical Engineering and 2020 IEEE Industrial and Commercial Power Systems Europe (EEEIC/I & CPS Europe), Madrid, Spain, 9–12 June 2020; pp. 1–5. [Google Scholar]
- Raza, M.Q.; Khosravi, A. A review on artificial intelligence based load demand forecasting techniques for smart grid and buildings. Renew. Sustain. Energy Rev.
**2015**, 50, 1352–1372. [Google Scholar] [CrossRef] - Hong, T. Short Term Electric Load Forecasting. Available online: https://repository.lib.ncsu.edu/bitstream/handle/1840.16/6457/etd.pdf?sequence=2&isAllowed=y (accessed on 20 December 2020).
- Xie, J.; Hong, T.; Stroud, J. Long-term retail energy forecasting with consideration of residential customer attrition. IEEE Trans. Smart Grid
**2015**, 6, 2245–2252. [Google Scholar] [CrossRef] - Hong, T.; Fan, S. Probabilistic electric load forecasting: A tutorial review. Int. J. Forecast.
**2016**, 32, 914–938. [Google Scholar] [CrossRef] - Hochreiter, S.; Schmidhuber, J. Long Short-Term Memory. Neural Comput.
**1997**, 9, 1735–1780. [Google Scholar] [CrossRef] [PubMed] - Gers, F.A.; Schmidhuber, J.; Cummins, F. Learning to forget: Continual prediction with LSTM. Neural Comput.
**2000**, 12, 2451–2471. [Google Scholar] [CrossRef] [PubMed] - Graves, A.; Fernández, S.; Schmidhuber, J. Bidirectional LSTM networks for improved phoneme classification and recognition. In International Conference on Artificial Neural Networks; Lecture Notes in Computer Science; Springer: Berlin/Heidelberg, Germany, 2005; Volume 3697, pp. 799–804. [Google Scholar]
- Bengio, Y.; Simard, P.; Frasconi, P. Learning Long-term Dependencies with Gradient Descent is Difficult. IEEE Trans. Neural Netw.
**1994**, 5, 157. [Google Scholar] [CrossRef] - Schmidhuber, J.; Wierstra, D.; Gagliolo, M.; Gomez, F. Training recurrent networks by Evolino. Neural Comput.
**2007**, 19, 757–779. [Google Scholar] [CrossRef] [Green Version] - Grubbs, F.E. Sample Criteria for Testing Outlying Observations. Ann. Math. Stat.
**1950**, 21, 27–58. [Google Scholar] [CrossRef] - Grubbs, F.E. Procedures for Detecting Outlying Observations in Samples. Technometrics
**1969**, 11, 1–21. [Google Scholar] [CrossRef] - Tietjen, G.L.; Moore, R.H. Some Grubbs-Type Statistics for the Detection of Several Outliers. Technometrics
**1972**, 14, 583–597. [Google Scholar] [CrossRef] - NIST/SEMATECH e-Handbook of Statistical Methods, 2554. Available online: https://www.itl.nist.gov/div898/handbook/ (accessed on 20 December 2020). [CrossRef]
- Zhang, S.; Liu, H.X.; Gao, D.T.; Wang, W. Surveying the methods of improving ANN generalization capability. In Proceedings of the 2003 International Conference on Machine Learning and Cybernetics, Xi’an, China, 5 November 2003; Volume 2, pp. 1259–1263. [Google Scholar] [CrossRef]
- Lusis, P.; Khalilpour, K.R.; Andrew, L.; Liebman, A. Short-term residential load forecasting: Impact of calendar effects and forecast granularity. Appl. Energy
**2017**, 205, 654–669. [Google Scholar] [CrossRef] - Monteiro, C.; Santos, T.; Fernandez-Jimenez, L.A.; Ramirez-Rosado, I.J.; Terreros-Olarte, M.S. Short-term power forecasting model for photovoltaic plants based on historical similarity. Energies
**2013**, 6, 2624–2643. [Google Scholar] [CrossRef] - Ulbricht, R.; Fischer, U.; Lehner, W.; Donker, H. First Steps Towards a Systematical Optimized Strategy for Solar Energy Supply Forecasting. In Proceedings of the European Conference on Machine Learning and Principles and Practice of Knowledge Discovery in Databases (ECMLPKDD 2013), Prague, Czech Republic, 23–27 September 2013; pp. 14–25. [Google Scholar]
- Coimbra, C.F.M.; Kleissl, J.; Marquez, R. Overview of Solar-Forecasting Methods and a Metric for Accurary Evaluation. In Solar Energy Forecasting and Resource Assessment; Elsevier: Amsterdam, The Netherlands, 2013; pp. 171–193. [Google Scholar]
- Nash, J.; Sutcliffe, J. River flow forecasting through conceptual models part I — A discussion of principles. J. Hydrol.
**1970**, 10, 282–290. [Google Scholar] [CrossRef] - McCuen, R.H.; Knight, Z.; Cutter, A.G. Evaluation of the Nash-Sutcliffe Efficiency Index. J. Hydrol. Eng.
**2006**, 11, 597–602. [Google Scholar] [CrossRef] - Pontes, F.J.; Amorim, G.F.; Balestrassi, P.P.; Paiva, A.P.; Ferreira, J.R. Design of experiments and focused grid search for neural network parameter optimization. Neurocomputing
**2016**, 186, 22–34. [Google Scholar] [CrossRef]

**Figure 4.**Available data samples aggregated in populations weekly wise visualization. For example, a single sampled quarter-hourly population is highlighted in orange.

**Figure 5.**Generalized ESD application: rejected samples (

**above**) and relevant p-value of the new population without outliers (

**below**).

Acronym | Load Forecasting Classification | Time Horizon |
---|---|---|

VSTLF | very short term | 1 day |

STLF | short term | 2 weeks |

MTLF | medium term | 3 years |

LTLF | long term | >3 years |

Methodology | Training Size (Days) | Test Size (Days) |
---|---|---|

No cleaning | 358 | 243 |

Holidays removal | 224 | 243 |

GESD | 358 | 243 |

Error removal | 308 | 243 |

Metric | No Removal | Holidays Removal | Outliers Removal | Error Removal |
---|---|---|---|---|

NMAE(%) | 4.11 | 3.70 | 3.30 | 3.37 |

nRMSE (%) | 7.80 | 6.43 | 4.93 | 5.30 |

E${}_{f}$ (-) | 0.54 | 0.68 | 0.81 | 0.79 |

Metric | Holidays Removal | Outliers Removal | Error Removal |
---|---|---|---|

NMAE | 10.0 | 19.8 | 18.0 |

nRMSE | 17.5 | 36.7 | 32.0 |

E${}_{f}$ | 27.7 | 52.0 | 48.3 |

Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |

© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Nespoli, A.; Ogliari, E.; Pretto, S.; Gavazzeni, M.; Vigani, S.; Paccanelli, F.
Electrical Load Forecast by Means of LSTM: The Impact of Data Quality. *Forecasting* **2021**, *3*, 91-101.
https://doi.org/10.3390/forecast3010006

**AMA Style**

Nespoli A, Ogliari E, Pretto S, Gavazzeni M, Vigani S, Paccanelli F.
Electrical Load Forecast by Means of LSTM: The Impact of Data Quality. *Forecasting*. 2021; 3(1):91-101.
https://doi.org/10.3390/forecast3010006

**Chicago/Turabian Style**

Nespoli, Alfredo, Emanuele Ogliari, Silvia Pretto, Michele Gavazzeni, Sonia Vigani, and Franco Paccanelli.
2021. "Electrical Load Forecast by Means of LSTM: The Impact of Data Quality" *Forecasting* 3, no. 1: 91-101.
https://doi.org/10.3390/forecast3010006