You are on page 1of 16

Available online at www.sciencedirect.

com
ScienceDirect

Energy Reports 9 (2023) 90–105


www.elsevier.com/locate/egyr

TMREES23-Fr, EURACA 06–08 February 2023, Metz-Grand Est, France

Data-driven prediction models of photovoltaic energy for smart grid


applications
Sonia Souabi, Asmae Chakir ∗, Mohamed Tabaa
Pluridisciplinary Laboratory of Research & Innovation (LPRI), EMSI Casablanca, Morocco
Received 20 May 2023; accepted 26 May 2023
Available online xxxx

Abstract
Due to the low total cost of production, photovoltaic energy is a key component of installed renewable energy worldwide.
However, photovoltaic energy is volatile in nature as it depends on weather conditions. This makes the integration, control,
and operation of this type of energy difficult for network operators. Therefore, renewable energy forecasting is emerging as a
key solution to effectively manage renewable energy in the power system. In this paper, we present a time series based energy
forecasting system using a solar home database. We worked on Australian data recorded from 2010 to 2013. Three large
databases have been combined to obtain better results. The objective is to test and compare the three prediction algorithms,
namely: LSTM, FFNN and GRU. We also compared the performances via RMSE, MAE and R2_score. The results showed
that neural networks accurately and reliably predict the energy consumed with R2_score up to 0.92 and MSE not exceeding
0.23, with a slight difference between the three models tested in this work.
© 2023 The Authors. Published by Elsevier Ltd. This is an open access article under the CC BY-NC-ND license
(http://creativecommons.org/licenses/by-nc-nd/4.0/).
Peer-review under responsibility of the scientific committee of the TMREES23-Fr, EURACA, 2023.

Keywords: Solar energy; Prediction; Timeseries; Performance

1. Introduction
A country’s progress is strongly correlated with its development and its energy self-reliance. Countries that
can handle their energy resources are able to satisfy their electrical needs and ensure the energy comfort of their
inhabitants, whatever the complexity of the constraints linked to changes in citizens’ electrical behavior [1]. This
evolution must not damage in any way the planet’s environment. This means constantly satisfying the energy demand
but thinking about integrating environmentally friendly energy solutions [2,3]. This is quite challenging with the
current electrical grid structure [4]. Indeed, it is known that the current electrical network is characterized by
a centralized production process that includes oversized power plants and a unidirectional production flow [5].
However, communication between consumers and producers is limited or even non-existent [6]. This type of
electrical grid is an obstacle to satisfy the constraints that are constantly recurring in all countries around the world.
∗ Corresponding author.
E-mail address: a.chakir@emsi.ma (A. Chakir).

https://doi.org/10.1016/j.egyr.2023.05.237
2352-4847/© 2023 The Authors. Published by Elsevier Ltd. This is an open access article under the CC BY-NC-ND license (http:
//creativecommons.org/licenses/by-nc-nd/4.0/).
Peer-review under responsibility of the scientific committee of the TMREES23-Fr, EURACA, 2023.
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

Nomenclature
CNN Convolutional neural network
ESN Echo state network
GAM Generalized Additive Models
ANN Artificial neural networks
FLS Fuzzy logic system
SVM Support vector machine
GCN Graph convolutional network
LSTM Long short-term memory
RNN Recurrent neural network
GBRT Gradient Boosted Regression Tree
SDG Stochastic gradient descent optimization
FFNN Feedforward Neural Network
GRU Gated Recurrent Unit
RMSE Root Mean Squared Error
MAE Mean Squared Error
R2 SCORE Coefficient of determination

Therefore, the progress towards an intelligent network that values the communication component and promote the
use of renewable energies is required [7,8].
The notion of smart grid brings together several technologies and solutions to produce, transport, communicate
and distribute energy in a more efficient way. This has allowed the smart grid to accept several definitions, each of
them tries to define the concept by considering a specific intelligence feature. Noting among others the definition
of the U.S. [9] (DOE) states that a smart grid is an electrical system that uses digital technology to improve the
reliability, safety, and efficiency of the electrical system, from large-scale generation to electricity end-users, through
distribution systems and distributed generation and storage resources.
Smart grid is a term used to refer to the communication and control facilities integrated into today’s power grid
to meet the needs of the 21st century. These communication facilities include both wired and wireless technologies.
Indeed, the main contribution of applying the intelligence to conventional power grids is to provide a bi-directional
flow of both energy and communication signals. This allows control and communication systems to react to changes
in any phase of the grid. These phases represent the major components of the power grid, namely: generation,
Transmission and Distribution (T&D) and consumption [10,11]. These components can be seen as the interaction of
several intelligent agents, belonging to the different components of the smart grid, placed in an electrical environment
and make autonomous and flexible decisions based on their embedded intelligence and previous experiences [8].
A smart grid must be able to satisfy its energy needs in compliance with the energy produced by the renewable
installations [12,13]. Therefore, the key elements for a smart grid are the consumption control [14], the production
management [15–17], and obviously the communication between all the grid actors. This communication is mainly
based on the data collection from both sides of the grid to make a decision that is well adapted to the situation [18]. In
other words, the objective of the communication component in the future smart grid is mainly to process and analyze
the data collected by sensors. These collectors are subject to weather stations, renewable production facilities that
are mainly correlated to meteorological conditions, namely: the photovoltaic system and wind turbines [19,20]. And
finally, the collection of data related to the residents’ electrical behavior to deduce or predict its consumption based
on time. These collected data are large and include useful information to understand the dynamics of electricity
consumption by the inhabitants, as well as the generation profile of the renewable systems installed to alternatively
supply the end consumers of electricity [21,22]. Consequently, these data are the subject of entries for an analysis
that leads to a prediction of energy production or power consumption during a given period [23,24].
The prediction of the electric production by means of renewable sources comes to know and make decisions
adapted to each application. Indeed, when the renewable production is used in small scale nominated by a
(HRES) [25,26], the data analysis comes to decide which energy should be used and when contribute to the energy
91
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

storage [27–29]. Also, to know when the renewable sources are available or reliable and when it is time to integrate
the storage system. Regarding large scale installations, knowing when the conventional sources will be used to
satisfy the renewable deficit is the goal of prediction process. Moreover, when small scale installations are injected
into a microgrid, whether autonomous or not, other economic constraints are involved in deciding when a microgrid
contributor want to sell in case of surplus or purchase energy in case of deficit [30].
Renewable energies are characterized by intermittency and therefore their prediction is required. This is equally
relevant if considering renewable generation for hybrid renewable energy systems attached to future homes. The
production prediction ensures a proper control of the energy that will be supplied to the users, thus a good or even
optimal energy management. In that sense, this study is dealing with a comparative study to find the most suitable
algorithm for the energy data. To do this, a database of solar production for smart homes has been considered and
the following algorithms: LSTM, FFNN and GRU, have been investigated and their performance was studied.
This paper is organized as follows. A background section is dressed in the second section. The third section is
devoted to present the followed methodology for energy prediction. Simulation, results and discussions are presented
in the fourth section. Otherwise, conclusion and future works are drawn at the end of the paper.

2. Background
To meet the demand for electricity and keep the environment clean, the use of alternative green energies is the
solution [31,32]. These sources are represented by renewable power generation, noting among others: solar energy,
wind turbines. These sources are green and contribute positively to the environment protection and lower greenhouse
gas emissions, although unfortunately they are characterized by intermittency [33]. This is coupled with several
constraints in renewable energy use and their connection to both conventional and smart electrical grids. Indeed,
the integration of these sources in the electrical network comes with several challenges, namely: the uncertainty of
energy availability, voltage, and frequency fluctuations as well as power electronics equipment control [34]. These
constraints restrict the widespread use of renewable energy sources in the smart grid, resulting a lack of renewable
energy reliance as a primary source in the grid that is always reinforced by large-scale conventional generation
sources, a diesel generator or storage facility at the residential level or small-scale microgrid applications [33,35,36].
For an increase in the renewable energy share of the grid and to build reliability, these constraints need to be cleared.
A system that incorporates this number of constraints to be satisfied and characterized by stochasticity is considered
as complex. For such a system, intelligent methods must be applied to control the system dynamics and satisfy its
constraints as well as predict its future behavior under different conditions [21,37,38]. This can be achieved by
so-called artificial intelligence. This discipline has been applied in many fields, such as energy for meteorological
data processing [39], solar system generation prediction [40], energy system intelligent control [41,42] or even
hybrid renewable energy system optimization [43,44].
Several researchers have tested the possibility to involve artificial intelligence for the renewable energy
forecasting, especially for its application in the smart grid, notably for the prediction of the energy produced by solar
systems, considered as a source globally used in numerous renewable applications, mostly for countries characterized
by an important solar potential [23]. Authors in Khan et al. [45] used Echo state network (ESN) to learn related time
feature combined to Convolutional neural network (CNN) for a learning of special feature to predict solar power
generation data set. The simulation and the evaluation using the popular data analysis metrics have shown that
the proposition achieved a considerable prediction for solar power generation and energy consumption. To reduce
the computational time presented by conventional optimization methods, authors in Lin et al. [46] have tested
two artificial techniques, namely: Generalized Additive Models (GAMs) and artificial neural networks (ANN) for
revenue prediction that helps for a market participation of a system based on hydropower and storage system. In
Cao et al. [47] , authors used a method based on recurrent type-3 (RT3) and fuzzy logic system (FLS) to estimate
the energy produced by a wind turbine power plan and a solar system. To predict the generation of a photovoltaic
plant authors in Li et al. [48] propose a multi-verse optimizer algorithm (HIMVO) combined to support vector
machine (SVM), this combination ensured based on results a certain level of accuracy and stability. Due to strong
renewable fluctuation, the prediction of renewable energy is complicated, so the solution is to learn at the same time
spatial and temporal features of renewable generation for a more accurate model prediction. Based on this approach
authors in Liao et al. [49] have proposed a method based on graph convolutional network (GCN) and long short-term
memory (LSTM) to learn dynamics of solar and wind power production. Furthermore, the data collected for solar
power generation sometimes could be subject to lack and missing of data which must be proceed before being
92
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

analyzed. For this reason, authors in Waczowicz et al. [50] have normalized and proceeded the data to solve the
problem of missing information using linear interpolation and automatic merging then used the Artificial Neural
Network (ANN) to predict the production of a solar system. Results shown that time series ANN with 6 layers
gave more reasonable and accurate values. Authors in Kaur et al. [51] proposed a method based on bidirectional
long short-term memory deep neural networks with variational inference to predict a power generation of PV, that
was very efficient to generate future prediction with more accuracy in presence of significant energy fluctuations.
Using the same technique, authors in Kaur et al. [52] have shown effectiveness of this method to lower error values
during forecasting, the demonstration was done by using it to predict the future generation of a PV plant in smart
grid context. By combining the LSTM with recurrent neural network (RNN), authors in Bandara et al. [53] was
able to predict the energy consumption related to time series and seasonal cycles. Especially that time series trained
algorithm give better results [54,55]. Based on the same data set and to predict the energy demand and the PV
power generation of six communities, authors in Pirbazari et al. [56] have used a method based on Gradient Boosted
Regression Tree (GBRT) combined to Sequence to-Sequence LSTM. Using multi-input single-output-LSTM and
tacking into consideration relationships between various households [57], a single household energy forecasting was
done. A new method was proposed by Laurinec and Lucká [58] to forecast energy consumption of consumers based
on clustering which increase the accuracy and decrease the time needed for calculation. Fore the same objective
authors in Wang et al. [59] have proposed to use Hierarchical clustering.

3. Methodology
3.1. Database description

We are working on data collected from 300 randomly selected solar customers in the Ausgrid power grid area.
The consumption data is recorded from July 1, 2010 to June 30, 2013. In this database, we hold two types of
consumption: general consumption for electricity always supplied, excluding solar generation and load-controlled
supply, and load-controlled consumption. Hence, to obtain the total consumption, we sum up the two types of
consumption for each date: the general consumption and the load-controlled consumption. The database contains
48 columns recording the general consumption and the load-controlled consumption for each half-hour.

3.2. Methodology

Our objective is to predict the total consumption (general consumption + load-controlled consumption) of the last
half-hour of the day based on the other recorded consumptions. The output of the model is the total consumption
of the last half-hour and the inputs of the system will be all the other consumptions. In this respect, we opted
for three neural network models: Feedforward Neural network, LSTM and GRU. We perform the tests on our
database considering the three models and then we compare the different results obtained based on the corresponding
evaluation metrics.
The first step is to divide the database into two parts: the training database and the test database. The percentage
is estimated to be 20/80. By testing the three models, the one involving the feedforward neural network, then LSTM
and GRU, we opt for several metrics to measure the performance and accuracy of the model.

3.3. Models description

3.3.1. Timeseries
A time series is a collection of data recorded over a regular period of time. Data can be collected at regular
intervals (e.g., every hour, every day, every week, every month, etc.) or at irregular intervals (e.g., every time an
event occurs). Time series are used in many fields. Time series data can contain trends, noise and special effects
to model and forecast future values. To model and forecast time series, neural networks can be applied. Neural
networks can be used for modeling complex and non-linear relationships between time series variables, which can
lead to more powerful models than other traditional statistical models.
In this respect, neural networks can also be deployed for different types of forecasting, such as short-term,
medium-term, and long-term forecasting. There are different types of neural networks for modeling time series,
such as recurrent neural networks (RNN), convolution neural networks (CNN), short- and long-term memory neural
93
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

networks (LSTM), and many others. In general, the use of neural networks to model time series can be very
powerful, but in most cases requires a large amount of data to train the models, which perfectly fits the case we
are studying.

3.3.2. Feedforward Neural Network


The Feedforward Neural Network algorithm is a machine-learning technique for predicting numerical values.
For energy consumption prediction, this algorithm can be used to predict the amount of energy consumed based on
specified inputs. The neural network is composed of several layers of interconnected neurons, each transforming
inputs into outputs through a non-linear function; the activation function. The layers of neurons are arranged in a
sequence, where the outputs of each layer present the inputs of the next layer, giving rise to the name “forward
propagation”.
In training the network, the weights of the connections between neurons are tuned to minimize a cost function
measuring the difference between the predicted outputs and the actual values of energy consumption. This
adjustment of weights is performed using an optimization algorithm. Once the network has been trained on a dataset,
it can be used to predict energy consumption for new inputs by simply applying forward propagation to the inputs
and getting the output from the last layer.
Our proposed energy consumption prediction model is based on a set of layers: 6 dense layers in total; the first
dense layer as input, 4 dense hidden layers and the last dense layer as output. The input dataset is prepared after
a data normalization operation. In a feed-forward neural network, one deal with two-dimensional input and output
data, i.e., data of the form [num Examples, input Size]. This means that the data in a feed-forward network consists
of “example number” rows. Each row is composed of “input Size” columns (Fig. 2). Similarly, the output data of
these networks is also two-dimensional, with a form [num Examples, output Size].
We have created a model containing 6 layers in total (Fig. 3). The first model we are dealing with is the
feedforward neural network with 4 hidden layers, using the ReLU activation function and a mean squared error
loss function. The model is trained on 100 epochs, with a batch size of 32. The number of units in each hidden
layer varies, assuming values of 50, 100, 150 and 200. The neural network starts with an input layer that receives
the input data. The input data is then transmitted to the first hidden layer. The values of each unit are calculated by
applying the ReLU activation function to a linear combination of the inputs. The outputs of the first hidden layer
are then transmitted to the second hidden layer, which will contain either 50 units, 100 units, 150 units or 200 units.
The same process is repeated for the following layers.
After the hidden layers, the outputs are passed to the output layer, which contains only one unit in this case,
where the loss function is a mean squared error. This layer computes a linear combination of the outputs of the
hidden layers, which is then compared to the expected output to compute the error. The error is then propagated
back through the network using the gradient backpropagation algorithm, and the weights are adjusted to minimize
the loss function. The model is trained over 100 epochs, meaning that the training data is passed through the neural
network 100 times. During each epoch, the data is divided into batches of 32 elements (batch size), and the weights
are updated at the end of each batch. After 100 epochs, the model returns the weights that minimize the loss function.
Adam (Adaptive Moment Estimation) is a popular optimization algorithm widely used in neural network training.
It is a stochastic gradient descent optimization (SGD) algorithm that computes adaptive learning rates for each
parameter based on the first and second moments of the gradients. Adam is known for its fast convergence, good
generalization performance and robustness to noisy or sparse gradients. The mean square error (MSE) is a loss
function frequently used in neural networks for regression problems. It measures the mean square difference between
the predicted and actual values. The MSE loss function is well suited for regression problems, where the objective
is to predict continuous values, and it provides a smooth and differentiable optimization surface that is easy to
optimize. As long as the context is considered as a regression problem, the Adam optimize and MSE as the loss
function were the suitable choices in this case (see Fig. 1).

3.3.3. LSTM
The Long Short-Term Memory (LSTM) algorithm is a variant of a recurrent neural network (RNN) used to
process sequences of data, for example, time series. Unlike traditional RNNs, the LSTM algorithm is designed to
process longer sequences. The “memory cells” used in the LSTM algorithm are capable of storing information over
long periods of time. In the context of time series, the LSTM algorithm can be successfully used to predict future
94
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

Fig. 1. Feedforward input data form.

Fig. 2. The proposed architecture based on Feedforward.

Fig. 3. Recurrent network input data form.

values in the series based on previous values. The LSTM algorithm is composed of several layers of LSTM cells.
Each LSTM cell contains a memory cell storing long-term information. The model incorporates the history of the
time series to make accurate predictions through the LSTM cells, which are designed to enable error propagation
through many time steps. Complex patterns can also be detected and captured by the LSTM cells.
The first step in our LSTM is to decide what information we are going to throw away from the cell state. This
decision is made by a sigmoid layer called the “forget gate layer”. It looks at h t−1 and xt , and outputs a number
95
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

between 0 and 1 for each number in the cell state Ct−1 . it represents “completely keep this” while a 0 represents
“completely get rid of this”. As explained by Eq. (1).
f t = σ (W f . [h t−1 , xt ] + b f ) (1)
The next step is to decide what new information to store in the cell state. This has two parts. First, a sigmoid
layer called the “input gate layer” decides which values we will update. Next, a tanh layer creates a vector of new
candidate values, Ct (Eq. (3)), that could be added to the state.
i t = σ (Wi . [h t−1 , xt ] + bi ) (2)
Ct = tanh(WC . [h t−1 , xt ] + bC ) (3)
It is now time to update the old cell state, Ct−1 , into the new cell state Ct . The previous steps already decided
what to do, we just need to actually do it.
We multiply the old state by f t , forgetting the things we decided to forget earlier. Then we add i t ∗ Ct . This is
the new candidate values, scaled by how much we decided to update each state value.
Ct = f t ∗ Ct−1 + i t ∗ Ct (4)
Finally, we need to decide what we are going to output. This output will be based on our cell state, but will be
a filtered version. First, we run a sigmoid layer which decides what parts of the cell state we are going to output.
Then, we put the cell state through tanh (to push the values to be between −1 and 1) and multiply it by the output
of the sigmoid gate, so that we only output the parts we decided to.
ot = σ (Wo . [h t−1 , xt ] + bo ) (5)
h t = ot ∗ tanh(Ct ) (6)
Our second model consists of a model based on LSTM, with the same number of layers considered in the first
model. For the LSTM, the data are time series. Therefore, we have 3 dimensions: an extra dimension for time. The
input data has a form [num Examples, input size, time series length], on the other hand, the output data has a form
[num Examples, output size, time series length]. Reshaping the data in this way allows the LSTM to learn from
the sequence information and the relationships between the features in the data (Fig. 3). The loss function used is
the mean squared error (MSE), the same function used in the first model measuring the mean squared deviation
between predicted and actual values.
The model has six layers in total (Fig. 4), which includes an input layer, four LSTM layers and an output layer.
The LSTM layers each contain a number of neurons, which can take several possible values. The activation function
used is the rectified linear unit (ReLU), which is a nonlinear function widely used in neural networks. The model
is trained for 100 epochs, i.e. it performs 100 iterations on the training data set. The batch size is 50, which means
that the model performs a weight update after processing 50 training examples at a time.

Fig. 4. The proposed architecture based on LSTM algorithm.

96
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

3.3.4. GRU
The GRU (Gated Recurrent Unit) algorithm is another type of recurrent neural network used for processing
data sequences, such as time series in our case. GRUs are similar to LSTMs in their use of gates to regulate the
flow of information in and out of the cell. However, GRUs are characterized by a simpler structure than LSTMs.
GRUs are designed with the objective of being more powerful in terms of efficiency than LSTMs, thus in terms of
computational time and computing resources, while maintaining a high capacity to capture patterns in the data. GRU
can be exploited in several tasks such as natural language processing, machine translation and text classification. The
GRU algorithm goes through several steps. First, it processes the input by dividing it into fixed-length sequences,
each sequence is then divided into feature vectors that are weighted by weight matrices. Reset and update gates are
then used for proper information management in the memory cell. An output weight matrix is used to generate the
output, and the update of the network weights is then performed through an error backpropagation algorithm.
Now let us see the functioning of these gates. To find the Hidden state h t in GRU, it follows a two-step process.
The first step is to generate what is known as the candidate hidden state. As shown by Eq. (7).
h t = tanh(xt ∗ Ug + (rt◦ h t−1 ) ∗ Wg ) (7)
It takes in the input and the hidden state from the previous timestamp t − 1 which is multiplied by the reset
gate output rt . Later passed this entire information to the tanh function, the resultant value is the candidate’s hidden
state.
Once we have the candidate state, it is used to generate the current hidden state h t . It is where the Update gate
comes into the picture. Now, this is a very interesting equation, instead of using a separate gate like in LSTM
in GRU we use a single update gate to control both the historical information which is h t−1 as well as the new
information which comes from the candidate state.
h t = u ◦t h t−1 + (1 − u t )◦ h t (8)
The third model consists in exploiting the GRU algorithm with the same inputs and the same output of the
previous models (Fig. 6). Same for the GRU, the data are time series as LSTM model. The same number of layers
is used as well, with 50 units for each layer except the last layer. We consider the same activation function: Relu
with the same loss function and the same optimizer (see Fig. 5).

Fig. 5. The proposed architecture based on GRU algorithm.

3.4. Evaluation metrics

In our study, several evaluation metrics were used. In the first place, the mean squared error has been adopted
as the loss function since this model is based on continuous variables. To measure the performance of our models,
three evaluation metrics were used:
RMSE (root-mean-squared-error): RMSE (Root Mean Squared Error) is a commonly used error measure in
evaluating the outcome of neural network models and other machine learning models. RMSE is defined as the
square root of the averaged squares of the differences between the model predictions and the actual values in the
97
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

Fig. 6. Loss function according to feedforward, LSTM and GRU.

test data set, as presented by Eq. (9).



ˆ 2
∑N 
i=1 y (i) − y(i)


RSM E = (9)
N
In other words, the RMSE measures the average difference between the predicted and actual values using the
sum of the squares of these differences, divided by the total number of examples N and taken as the square root.
The smaller the RMSE, the better the performance of the model as this indicates that the predictions are closer to
the actual values.
MSE: MSE (Mean Squared Error) is a common metric used to evaluate the performance of neural network
models. MSE measures the mean squared error between the model predictions and the actual values in the test
data set. Suppose we have a test dataset with N examples, where each example i has an actual value yi and a
corresponding model prediction ŷi . Then the MSE is computed by Eq. (10).
(yi − ŷi )2

MSE = (10)
N
R2 score: The R2 score, also known as the coefficient of determination, is a common performance measure used
to evaluate the quality of neural network models. The R2 score measures how well the model’s predictions meet
the actual values in the test data set. Suppose we have a test data set with N examples, where each example i has
a real value yi and a corresponding model prediction ŷi . Then the R2 score is calculated using Eq. (11).
∑n
(yi − ŷi )2
R2 score = 1 − ∑ni=1 2
(11)
i=1 (yi − y i )

4. Results and discussion


The results presented in this section are obtained after the implementation of three models: Feedforward neural
network, LSTM and GRU. The three models consider 4 hidden layers with several possible values of units: 50,
100, 150, 180 or 200.
The results reveal that for each model (feedforward neural network, LSTM and GRU), increasing the number of
units in the network generally leads to a decrease in data loss. This implies that adding more capacity to the model
results in better prediction performance. However, it is worth noting that this is not always the case and that adding
too much capacity can lead to overfitting.
For the results provided, the loss values for the feedforward neural network models range from 0.00117 with
50 units to 0.000742 with 200 units (Table 1). The loss values for the LSTM model vary from 0.00086 with 50
units to 0.0007 with 200 units. The GRU model’s loss values range from 0.00081 with 50 units to 0.00067 with
98
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

Table 1. Loss function according to the three models


and number of units.
Model Number of units Loss
50 0,00117
Feedforward neural 100 0,0008
network 150 0,00084
200 0,000742
50 0,00086
100 0,000732
LSTM
150 0,000774
200 0, 0007
50 0,00081
100 0.00067
GRU
150 0.00079
180 0.001

100 units (Fig. 6). These results indicate that increasing the capacity of the model, by increasing the number of
units, leads overall to an improvement in the prediction accuracy of the training data. From Fig. 6, it appears that
the two algorithms LSTM and feedforward neural network provide very similar curves from 100 no. of units. For
150 units, the three algorithms produce approximately equal values.
The results suggest that for each model, increasing the number of units generally leads to lower loss values,
with some exceptions. The LSTM and GRU models generally outperform the feedforward neural network, with the
GRU model achieving the lowest loss value overall.
The results provided reveal that all the neural network architectures studied (Feedforward, LSTM and GRU) have
very similar performance in terms of RMSE, MSE and R2 score for the prediction of the target variable (Table 2).
In all cases, increasing the number of units generally resulted in improved prediction performance.

Table 2. Evaluation metrics (RMSE, MSE, R2_score) for the three models according to
number of units.
Model Number of units RMSE MSE R2_SCORE
50 0,0342 0.02214 0.932
Feedforward neural 100 0.029 0.02 0.95
network 150 0.028 0.0185 0.95
200 0.0725 0.01735 0.95717
50 0.02945 0.01945 0.95
100 0.02706 0. ç018 0.95776
LSTM
150 0.0278 0.01826 0.9553
200 0.0276 0.01765 0.9558
50 0.02858 0.0183 0.9528
100 0.0259 0.01695 0.9612
GRU
150 0.02826 0.0192 0.9532
180 0.0328 0.02186 0.9377

In general, lower RMSE and MSE values indicate better prediction accuracy, while higher R2 score values
indicate a better ability of the model to explain variance in the data. The RMSE and MSE values are related
and measure the average prediction error of the model. The R2 score measures the proportion of total variance in
the data that is explained by the model.
In terms of the algorithms’ relative performance, the results highlight that the LSTM model tends to have the
best performance in terms of RMSE and MAE (Figs. 8,9), while the GRU model tends to have the best performance
in terms of R2 score (Fig. 10). However, the difference in performance between the models is not very important,
suggesting that all three algorithms are suitable for the prediction task and have similar performance. With respect
99
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

to the numerical values, we observe that the differences in performance are relatively small. For instance, for the
Feedforward model, the difference in RMSE between 50 and 200 units is about 0.04, and the difference in R2 score
is only 0.025.
The results obtained by these algorithms demonstrate high accuracy (Figs. 11, 12, 13). This indicates that
they were able to capture the patterns and trends in the historical energy consumption data, making use of this
information to make accurate predictions about future energy consumption. Furthermore, the curves of the actual
values with the predicted values indicate a high accuracy between the two: this implies that the forecasts generated
by the feedforward, LSTM and GRU algorithms are very approximate to reality (Figs. 11–13). In other words, the
predictions are very highly accurate and can be employed to help plan and manage energy consumption effectively.
Based on these results, it can be concluded that all three models (Feedforward Neural Network, LSTM and GRU)
predicted the target variable well. However, the LSTM model produced the best results in terms of RMSE, MSE
and R2 SCORE, with the lowest values. The Feedforward Neural Network model also performed well, especially
with unit counts of 100 and 150. The GRU model also produced good results, but not as good as the LSTM model
or the Feedforward Neural Network model with 100 and 150 units.
In conclusion, the good results obtained by the feedforward, LSTM and GRU algorithms for energy consumption
prediction are an indication of their effectiveness in capturing patterns and trends in historical energy consumption
data, and in producing accurate forecasts for future energy consumption (see Fig. 7).

Fig. 7. Root Mean squared error according to number of units.

5. Conclusion and future works


Our work involved predicting energy consumption in a time series setting using a domestic solar electricity
database. The consumption was predicted during the last half hour according to the other recorded consumptions.
To this end, we used three different models: a feedforward neural network, an LSTM and a GRU. Then, we compared
the performance of the three models was compared using the evaluation metrics RMSE, MAE and R2 score. The
results reveal that all three algorithms performed well in terms of energy consumption prediction. The comparison
between the actual and predicted values indicated that the neural networks achieved accurate and reliable predictions,
despite slight differences between the three models. Considering the size of the database, the use of recurrent neural
networks was a wise choice to achieve high accuracy. Overall, our work has demonstrated that the application of
neural networks in time series is a promising area for predicting energy consumption, which may have important
implications for energy management and planning in the future. In the future, our focus will be on:
• Exploring other types of neural networks that could potentially improve time series modeling.
• Applying these types of neural networks to other time series data sets.
100
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

Fig. 8. Mean absolute error according to number of units.

Fig. 9. R2_score according to number of units.

• Explore new aspects and influences of neural networks on energy consumption and production in other
contexts.

Declaration of competing interest


The authors declare that they have no known competing financial interests or personal relationships that could
have appeared to influence the work reported in this paper.

Data availability
Data will be made available on request.
101
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

Fig. 10. Real values vs predicted values according to feedforward algorithm.

Fig. 11. Real values vs predicted values according to GRU algorithm.

102
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

Fig. 12. Real values vs predicted values according to LSTM algorithm.

Fig. 13. Comparing real values with predicted values of the three models.

103
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

References
[1] Ouedraogo NS. Africa energy future: Alternative scenarios and their implications for sustainable development strategies. Energy Policy
2017. http://dx.doi.org/10.1016/j.enpol.2017.03.021, Epub ahead of print.
[2] Kousksou T, Allouhi A, Belattar M, et al. Renewable energy potential and national policy directions for sustainable development in
Morocco. Renew Sustain Energy Rev 2015;47:46–57.
[3] Scholten D, Bazilian M, Overland I, et al. The geopolitics of renewables: New board, new game. Energy Policy 2020;111059.
[4] Majeed Butt O, Zulqarnain M, Majeed Butt T. Recent advancement in smart grid technology: Future prospects in the electrical power
network. Ain Shams Eng J 2021;12:687–95.
[5] el Mostafa J, Zejli D, Komendantova N. Dynamics of Energy Transition in Morocco: Centralized versus Decentralized Options.
[6] Strielkowski W. Consumers, prosumers, and the smart grids. In: Social impacts of smart grids. Elsevier; 2020, p. 191–238.
[7] Avancini DB, Rodrigues JJPC, Martins SGB, et al. Energy meters evolution in smart grids: A review. J Clean Prod 2019;217:702–15.
[8] Malik FH, Lehtonen M. A review: Agents in smart grids. Electr Power Syst Res 2016;131:71–9.
[9] Department of energy. 2023, https://www.energy.gov/sites/prod/files/oeprod/DocumentsandMedia/DOE_SG_Book_. [Accessed 20
February 2023].
[10] Kabalci Y. A survey on smart metering and smart grid communication. Renew Sustain Energy Rev 2016;57:302–18.
[11] Lamnatou C, Chemisana D, Cristofari C. Smart grids and smart technologies in relation to photovoltaics, storage systems, buildings
and the environment. Renew Energy 2022;185:1376–91.
[12] Chakir A, Tabaa M, Moutaouakkil F, et al. Smart multi-level energy management algorithm for grid-connected hybrid renewable energy
systems in a micro-grid context. J Renew Sustain Energy 2020;12:055301.
[13] Abdi H, Beigvand SD, Scala Mla. A review of optimal power flow studies applied to smart grids and microgrids. Renew Sustain
Energy Rev 2017;71:742–66.
[14] Chakir A, Tabaa M, Moutaouakkil F, et al. A combined source and demand-side energy management system for a grid-connected
PV-wind hybrid system. In: Innovations in smart cities applications. 3rd ed. 2020, p. 707–21.
[15] Chakir A, Monteiro F. Energy storage management for building critical loads using home to vehicle and vehicle to home strategy. In:
2022 international conference on microelectronics. 2022, p. 266–9.
[16] Chakir A, Tabaa M, Moutaouakkil F, et al. Optimal energy management for a grid connected PV-battery system. Energy Rep 2020;6.
http://dx.doi.org/10.1016/j.egyr.2019.10.040, Epub ahead of print.
[17] Chakir A, Abid M, Tabaa M, et al. Demand-side management strategy in a smart home using electric vehicle and hybrid renewable
energy system. Energy Rep 2022;8:383–93.
[18] Chakir A, Abid M, Tabaa M, et al. Demand-side management strategy in a smart home using electric vehicle and hybrid renewable
energy system. Energy Rep 2022;8:383–93.
[19] Khare V, Nema S, Baredar P. Solar-wind hybrid renewable energy system: A review. Renew Sustain Energy Rev 2016;58:23–33.
[20] Ganguly P, Kalam A, Zayegh A. Solar-wind hybrid renewable energy system: Current status of research on configurations, control,
and sizing methodologies. In: Hybrid-renewable energy systems in microgrids: Integration, developments and control. Elsevier; 2018,
p. 219–48.
[21] Chen C, Hu Y, Marimuthu K, et al. Artificial intelligence on economic evaluation of energy efficiency and renewable energy
technologies. Sustain Energy Technol Assess 2021;47:101358.
[22] ben Slama S. Prosumer in smart grids based on intelligent edge computing: A review on artificial intelligence scheduling techniques.
Ain Shams Eng J 2022;13:101504.
[23] Sunny M, Kabir M, et al. Residential energy management: A machine learning perspective. ieeexplore.ieee.org; 2021, https://ieeexplore.
ieee.org/abstract/document/9289737/. [Accessed 21 February 2023].
[24] Berghout T, Benbouzid M, Muyeen SM. Machine learning for cybersecurity in smart grids: A comprehensive review-based study on
methods, solutions, and prospects. Int J Crit Infrastruct Prot 2022;38:100547.
[25] Ammari C, Belatrache D, Touhami B, et al. Sizing optimization, control and energy management of hybrid renewable energy system—A
review. Energy Built Environ 2022;3:399–411.
[26] Abdin Z, Mérida W. Hybrid energy systems for off-grid power supply and hydrogen production based on renewable energy: A
techno-economic analysis. Energy Convers Manag 2019;196:1068–79.
[27] Ahmad T, Madonski R, Zhang D, et al. Data-driven probabilistic machine learning in sustainable smart energy/smart energy systems:
Key developments, challenges, and future research opportunities in the context of smart grid paradigm. Renew Sustain Energy Rev
2022;160:112128.
[28] Liu Z, Sun Y, Xing C, et al. Artificial intelligence powered large-scale renewable integrations in multi-energy systems for carbon
neutrality transition: Challenges and future perspectives. Energy AI 2022;10:100195.
[29] Zhou Y. Artificial intelligence in renewable systems for transformation towards intelligent buildings. Energy AI 2022;10:100182.
[30] Liu Z, Sun Y, Xing C, et al. Artificial intelligence powered large-scale renewable integrations in multi-energy systems for carbon
neutrality transition: Challenges and future perspectives. Energy AI 2022;10:100195.
[31] Olabi AG, Abdelkareem MA. Renewable energy and climate change. Renew Sustain Energy Rev 2022;158:112111.
[32] Bajpai P. Renewable energy versus fossil resources. In: Biotechnology in the chemical industry. Elsevier; 2020, p. 23–30.
[33] Yang Y. Electricity interconnection with intermittent renewables. J Environ Econ Manage 2022;113:102653.
[34] Fazal S, Enamul Haque M, Taufiqul Arif M, et al. Grid integration impacts and control strategies for renewable based microgrid.
Sustain Energy Technol Assess 2023;56:103069.
[35] Redko A, Redko O, DiPippo R. Hybrid systems with renewable energy sources. In: Low-temperature energy systems with applications
of renewable energy. Elsevier; 2020, p. 289–328.
104
S. Souabi, A. Chakir and M. Tabaa Energy Reports 9 (2023) 90–105

[36] Kempton W. Analysis: Large-scale integration of renewable energy. In: Renewable energy systems: A smart energy systems approach
to the choice and modeling of 100% renewable solutions. 2nd ed. Elsevier Inc.; 2014, p. 79–129.
[37] Zhang L, Ling J, Lin M. Artificial intelligence in renewable energy: A comprehensive bibliometric analysis. Energy Rep
2022;8:14072–88.
[38] Boza P, Evgeniou T. Artificial intelligence to support the integration of variable renewable energy sources to the power system. Appl
Energy 2021;290:116754.
[39] Yang Z, Wang J. A hybrid forecasting approach applied in wind speed forecasting based on a data processing strategy and an optimized
artificial intelligence algorithm. 2018, http://dx.doi.org/10.1016/j.energy.2018.07.005, Epub ahead of print.
[40] Kim EG, Akhtar MS, Yang OB. Designing solar power generation output forecasting methods using time series algorithms. Electr
Power Syst Res 2023;216:109073.
[41] Chegari B, Tabaa M, Simeu E, et al. Multi-objective optimization of building energy performance and indoor thermal comfort by
combining artificial neural networks and metaheuristic algorithms. Energy Build 2021;239:110839.
[42] Agouzoul A, Chegari B, Tabaa M, et al. Using neural network in a model-based predictive control loop to enhance energy performance
of buildings. Energy Rep 2022;8:1196–207.
[43] Roseline JF, Dhanya D, Selvan S, et al. Neural network modelling for prediction of energy in hybrid renewable energy systems. Energy
Rep 2022;8:999–1008.
[44] Qadrdan M, Xu X, Haghi E, et al. Renewable power generation. In: Design and operation of solid oxide fuel cells. Elsevier; 2020, p.
297–310.
[45] Khan ZA, Hussain T, Haq IU, et al. Towards efficient and effective renewable energy prediction via deep learning. Energy Rep
2022;8:10230–43.
[46] Lin Y, Li B, Moiser TM, et al. Revenue prediction for integrated renewable energy and energy storage system using machine learning
techniques. J Energy Storage 2022;50:104123.
[47] Cao Y, Raise A, Mohammadzadeh A, et al. Deep learned recurrent type-3 fuzzy system: Application for renewable energy
modeling/prediction. Energy Rep 2021;7:8115–27.
[48] Li LL, Wen SY, Tseng ML, et al. Renewable energy prediction: A novel short-term prediction model of photovoltaic output power. J
Clean Prod 2019;228:359–75.
[49] Liao W, Bak-Jensen B, Pillai JR, et al. Short-term power prediction for renewable energy using hybrid graph convolutional network
and long short-term memory approach. Electr Power Syst Res 2022;211:108614.
[50] Waczowicz S, Sci C, Dev R, et al. Photovoltaic power forecasting using simple data-driven models without weather, vol.32. Springer;
2017, p. 237–46.
[51] Kaur D, Islam S, International MM-2021 I, et al. A variational autoencoder-based dimensionality reduction technique for generation
forecasting in cyber-physical smart grids. ieeexplore.ieee.org, http://dx.doi.org/10.1109/ICCWorkshops50388.2021.9473748.
[52] Kaur D, Islam SN, MdA Mahmud. Bayesian deep learning technique for multi-step ahead solar generation forecasting. 2022,
http://dx.doi.org/10.48550/arxiv.2203.11379, Epub ahead of print.
[53] Bandara K, et al. LSTM-msnet: Leveraging forecasts on sets of related time series with multiple seasonal patterns. 2020, https:
//ieeexplore.ieee.org/abstract/document/9075431/. [Accessed 21 February 2023].
[54] Bandara K, Hewamalage H, Liu Y-H, et al. Improving the accuracy of global forecasting models using time series data augmentation.
Elsevier, https://www.sciencedirect.com/science/article/pii/S0031320321003356. [Accessed 21 February 2023].
[55] Godahewa R, Bandara K, Webb GI, et al. Ensembles of localised models for time series forecasting. Elsevier, https://www.sciencedirect.
com/science/article/pii/S0950705121007802. [Accessed 21 February 2023].
[56] Pirbazari A, Sharma E, et al. An ensemble approach for multi-step ahead energy forecasting of household communities.
ieeexplore.ieee.org; 2023, https://ieeexplore.ieee.org/abstract/document/9366871/. [Accessed 21 February 2023].
[57] Razavi S, Arefi A, Ledwich G, et al. From load to net energy forecasting: Short-term residential forecasting for the blend of load and
PV behind the meter. ieeexplore.ieee.org, https://ieeexplore.ieee.org/abstract/document/9292948/. [Accessed 21 February 2023].
[58] Laurinec P, Lucká M. Clustering-based forecasting method for individual consumers electricity load using time series representations.
Open Comput Sci 2018;8:38–50.
[59] Wang Y, Chen Q, Sun M, et al. An ensemble forecasting method for the aggregated load with subprofiles. ieeexplore.ieee.org,
https://ieeexplore.ieee.org/abstract/document/8299478/. [Accessed 21 February 2023].

105

You might also like