Hybrid Artificial Neural Networks For Electricity Consumption Prediction
Hybrid Artificial Neural Networks For Electricity Consumption Prediction
Hybrid Artificial Neural Networks For Electricity Consumption Prediction
IFRS - Instituto Federal de Educação, Ciências e Tecnologia do Rio Grande do Sul – Campus Farroupilha, Brazil
Email: [email protected]
networks of the brain, how neurons work, pass and store more or less regular, around a trend line or curve.
information [13; 24]. Seasonalities are regular patterns observed from time to
Due to the accelerated development of computing time. Finally, randomness is effects that occur randomly
technology, ANN has provided a powerful framework for and that cannot be captured by cycles, trends and
supervised learning [5]. Deep learning allows models seasonalities.
composed of multiple layers to learn data representations Thus, the time series prediction models most used
[11]. Deep Neural Networks (DNN1 ) are inspired by the in the literature are those of linear and polynomial
structure of mammalian visual systems and they are also regressions. Among the regression models, we can
an important machine learning tool that has been widely mention the SARIMAX method [19]. This statistical
used in many fields [25]. DNN employs an architecture of model is a variant of the autoregressive moving average
multiple layers of neurons in an ANN and can represent model (ARMA), adding derivations to make the model
functions with higher complexity [5]. stationary (I), adding seasonality (S) and finally adding the
This work aimed at predicting the electricity effect of eXogenous (X) or random variables over time. In
consumption of a commercial building using ANN in its this work, the SARIMAX model was used as a baseline to
various architectures. Several ANN architectures were compare its results, its application to the test case and the
used and tested and a hybrid architecture (Dense, results obtained from other prediction models.
Convolutional and Recurrent), originally described by Lai,
G. et al. [4] and adapted for this case study, was selected. 2.2 Convolutional Artificial Neural Networks
Convective Artificial Neural Networks (CNN2 ) are a type
II. FOUNDATION of DNN that is commonly applied to analyse images. One
2.1 Time Series of the main attributes of CNN is to drive different
processing layers that generate an effective representation
Time series are sets of observations ordered in time [14].
of the features of image edges. The architecture of CNN
A temporal series can be defined as a class of phenomena
allows multiple layers of these processing units to be
whose observational process and consequent numerical
stacked, this deep learning model can emphasize the
quantification generate a sequence of observations
relevance of features at different scales [24].
distributed over time.
Fig. 1 demonstrates a typical architecture of a
Electricity consumption histories over time are
CNN, composed of at least, a convolution layer, a pooling
univalued time series [20] with trends, cycles, seasonality
layer, a flattening layer and dense layers.
and randomness. Trends are long-term characteristics
related to a time interval. Cycles are long-term oscillations,
2 CNN - Convolutional Neural Network
1 DNN - Deep Neural Network
In the convolution layer, a filter (kernel, which is the matrix product of the matrix colored in Fig. 2 by the
also a matrix) is applied to the input matrix aiming at its kernel, at each step it shifts one position to the right until
reduction while maintaining its most important the last column of the input matrix after it shifts one line
characteristics. Fig. 2 represents, step by step, the down and continues the process until it runs through the
application of the convolution function where g(x,y) whole input matrix. In the example of Fig. 2, a 7X7 input
represents the element of the convolution matrix, that is matrix was reduced to a 5X5 convolution matrix. The
whole process represented in Fig. 2 is repeated for each of For the pooling layer, it is usual to apply the
the kernels used, generating several convolution matrices. activation function relu f ( x )= max
( 0, x) for example,
a b generating a new reduced matrix as shown in Fig. 3.
g ( x, y ) = ω f ( x, y ) = ω ( dx,dy ) f ( x+ dx, y + dy )
dx= a dy= b Finally, the flattening layer is nothing more than
transforming the matrices of the pooling layers into
vectors, which will be the inputs of the dense layer.
2.3 Recurrent Artificial Neural Networks calculated so far. In theory, RNNs can make use of
In traditional ANNs, the inputs (and outputs) are information in arbitrarily long sequences, but in practice,
independent of each other, making it difficult to use them, they are limited to looking back only a few steps. Fig. 4 is
for example, in natural language processing where a word a typical representation of an RNN.
in a sentence depends on previous words in the same
sentence, or in time series where we need to know the
values over time for better projections.
In contrast, recurrent artificial neural networks
(RNN3) [8] store their previous state and also use it as
input to the current state for calculations of new outputs.
Another way of thinking about RNNs is that they have a
"memory" that captures information about what has been Fig. 4: Basic RNN.
Source: The Author.
3 RNN - Recurrent Neural Network
Fig. 4 shows an RNN being expanded into a data of sectors of Building N of ISEP/IPP where GECAD
complete network. Where xt is the input in time step t . For is located. The building has five energy meters that store
x1 the electrical energy consumption data of specific sectors
example, could be a one-hot vector corresponding to the
of the building, with a time interval of 10 seconds. This
second word of a sentence, st is the hidden state in the information, as well as meteorological data, are stored in a
time step t . It is the "memory" of the network. st Is SQL server automatically, through agents developed in
calculated based on the previous hidden state and the input Java.
s = f ( U xt +W st+1)
in the current time step: t . The function f To validate the model described below, tests were
is usually a nonlinearity, such as tanh or relu. s− 1, which performed using the same consumption data applied to the
SARIMAX model and HyFIS2. The N Building
is needed to compute the first hidden state, is usually
laboratories sector was not computed as it has a large
initialized with zeros. ot is the output in step t . For
variation in consumption due to the experiments conducted
example, if we wanted to predict the next word in a there, which generate many outliers in the consumption
sentence, it would be a probability vector in our history. For the experiment tests, it was performed an
o = softmax (V st ) .
vocabulary. t By expanding, we simply hourly average of the consumption stored every ten
mean that we write the network for the complete sequence. seconds, due to the need of predicting the next hour of
For example, if the sequence we are interested in is a 5- consumption.
word sentence, the network would be unfolded into a 5- 3.1 The Long and Short Time series Network Adapted
layer neural network, one layer for each word. (LSTNetA) Model
The model developed for energy consumption prediction
III. MATERIAL and METHODS was based on the model proposed by Lai [4], represented
This work was carried out at the Research Group on in Fig. 4, which consists of a hybrid ANN with three
Intelligent Engineering and Computing for Advanced distinct layers, initially has a convolutional layer for the
Innovation and Development (GECAD4), a research centre extraction of short-term patterns of the time series, has as
located at the Instituto Superior de Engenharia do Porto of input the time series, the output of this layer is the input of
the Instituto Politécnico do Porto ISEP/IPP, Porto, the recurrent layer that memorizes historical information
Portugal. Similarly to the HyFIS2 model (Josi et al.; 2016), of the time series, which in turn its output is the input of
the posited model uses the actual electrical consumption the highly connected dense layer. Finally, the output of the
highly connected layer is combined with the output of the
4 autoregressive linear regression (ARMA) [26] ensuring
http://www.gecad.isep.ipp.pt/GECAD/Pages/Pubs/Publ that the output will have the same scale as the input, thus
icationsPES.aspx composing the prediction.
Fig. 6 summarizes the implementation of the Dense classes, the auto-regression is represented in the
LSTNetA network. The convolution layer is represented PostARTrans class.
by the Conv2D class, the recurrent layer is represented by It is important to note that the recurrent layer uses
the GRU classes, the dense layer is represented by the one of the RNN variants the GRU (Gated Recurrent Unit)
4000
2000
Fig. 11. Neuro-Fuzzy structure of the HyFIS2 model.
0
Source: Jozi [9]
1 13 25 37 49 61 73 85 97 109
Hours
For prediction of electricity consumption, as in all
models tested, the last 120 historical records were used,
Fig. 10. Verified errors of the SARIMAX method. corresponding to five days of consumption. The
Source: The author. comparison between real and predicted consumption is
shown in Fig. 12. Fig. 13 shows the RMSE errors
calculated. The application of this model resulted in an
4.2 Model HyFIS2 average RMSE of 602.71 which was considered the
The HyFIS2 (Hybrid neural Fuzzy Inference System) accuracy of this model, in this work.
model uses a hybrid approach with the combination of
dense ANN and fuzzy logic. The system includes five
layers, as shown in Fig. 11. In the first layer, the nodes are
the inputs that transmit signals to the next layer. In the
second and fourth layers, the nodes act as membership
functions to express the input-output fuzzy linguistic Fig. 12. Real Consumption Comparison X HyFis2.
variables. In these layers, the fuzzy sets defined for the Source: The Author.
input-output variables are represented as: large (L),
medium (M) and small (S). However, for some
6000
applications, these can be more specific and represented
4000
Error
as, for example, large positive (LP), small positive (SP), 2000
zero (ZE), small negative (SN) and large negative (LN). In 0
the third layer, each node is a rule node and represents a 1 13 25 37 49 61 73 85 97 109
Hours
fuzzy rule. The connection weights between the third and
the fourth layer represent certainty factors of the associated Fig. 13. Verified errors of the HyFIS2 model.
rules, i.e., each rule is activated and controlled by the Source: The Author.
weight values. Finally, the fifth layer contains the node
that represents the output of the system.
V. APPLICATION OF THE LSTNETA MODEL
The training of the LSTNetA ANN was
performed as previously described, using the data of the
real electricity consumption of the N building of the
ISEP/IPP where GECAD is located, except for the
laboratory sector. The historical series analyzed was from
zero hours on 08/04/2019 to eight hours on 20/12/2019,
with measurements every ten seconds, totaled every hour,
resulting in 4186 records, containing time and
consumption. The training was performed with a learning
rate of 0.0003, using the Adam [10] stochastic method of of the real consumption of electricity, where the red line,
gradient descent optimization for updating the weights in which represents the predictions of the LSTNetA model, in
the backpropagation process. For the initial weights of the most of the period overlapped the blue line that represents
ANN, the algorithm VarianceScaling [3] was used, which the real consumption. This demonstrates a prediction very
generates initial weights with values on the same scale as close to the real consumption value, with low errors.
the inputs. The convolution kernel used was a 6x6 identity Table 1. Fragment of Predictions and Errors of the 3
matrix and a training loop with 1000 epochs was models
performed. All these parameters were obtained
Date and Actual LSTNetA Error - HyFis2 Error - SARI Error -
experimentally and the ones with the best results were Time LSTNetA HyFis2 MAX
selected. Consum SARIMAX
ption