Abstract

According to the stability process of smart grids, which starts by gathering information of consumers, and then evaluating this information based on specifications of a power supply, and finally, information of a price is sent to the consumers as a report about the utilization. From this perspective, this process is too much time consuming, thus it should predict a smart grid stability via artificial intelligence (e.g., neural networks). Recent advances in the accuracy of neural network have effective solutions to solving the smart grid stability prediction issues, but it remains necessary to develop high performance neural networks that give higher accuracy. In this paper, an artificial neural network (ANN) is proposed to predict a smart grid stability for Decentral Smart Grid Control (DSGC) systems. This neural network is applied to a dataset aggregated from simulations of grid stability, executed on a four-node network with star topology, and engaged in two classes of grid stability–stable and unstable. Keras framework is used to train the proposed neural network, and a hyperparameter tuning method is utilized to achieve high accuracy. Receiver operating characteristic (ROC) curves and confusion matrices are experimentally utilized to evaluate the performance of the proposed neural network. The neural network provides high performance, with a testing loss rate of 0.0619, and a testing accuracy of 97.36%. The weighted average recall, precision, and F1-score for the proposed neural network are 98.02%, 98.03%, and 98.02%, respectively, while the area under the ROC curves (AUCs) is 100%. This neural network with the utilized dataset indeed provides an accurate and quick approach of predicting grid stability to analyze DSGC systems.

1. Introduction

In the world, the rise in population led to increasing electricity consumption, thus, the appearance of renewable energy, in addition to conventional grids, which comprised of little generation centers that provided energy to consumers [1]. However, with the rising of renewable energy came a hybrid of these two called “prosumers,” which supply and consume energy. Thus, these prosumers need energy flow in a grid to be bidirectional. Also, these prosumers come with the more complex energy distribution, generation, and consumption. Accordingly, monetary ramifications related to these prosumers and renewable energy, particularly the decision of whether to purchase or not to purchase energy at known cost, have too become more challenging [2]. Moreover, significant attention has been devoted to the research on smart grids stability [3].

Smart grids can aggregate information about consumers for creating a system to distribute the power effectively. Smart grids reduce the requirements to deploy more power plants for dissipation of electricity [46]. Also, smart grids utilize renewable energy resources to become safe plugged into a grid to appendage a power supply. Smart grids can assist to make the electricity price much low cost and reduce the pollution. These grids evaluate information with respect to current supply information after gathering information from consumers demand, then obtain a cost value for the electricity and transmit this cost information to the customers to take decision about the usage. Because this process is time dependent, predicting a smart grid stability is one of the main necessities of such systems.

The artificial intelligence (AI), for instance deep neural networks [79] and machine learning [10, 11] have revolutionized in the process of energy production and distribution. It also played a significant role in smart grid stabilities prediction for residential loads [12]. Recurrent-neural networks (RNNS) have been proposed for accurately predicting a smart grid stability [13]. However, RNNS do not often reach satisfactory levels of accuracy. Feed-forward neural networks (FNNS) introduce effective solutions to tackle the problem of low accuracy. These neural networks are already feasible in such applications as image processing [14], and speech recognition [15], and are applicable for predicting smart grid stabilities. Figure 1 shows smart grid components. It is clear that there are many interactions between power sources, distribution stations, and various entities, such as smart cities, electric vehicles, factories, and smart buildings [16].

In the literature, smart grids utilized many artificial intelligence (AI) techniques, such as machine learning, artificial neural networks, and deep learning, for efficient energy consumption. In [17], various algorithms of deep learning were proposed to predict electrical loads for a smart grid. The authors concentrate on the utilization of various applications of deep learning for load prediction in the smart grid. Also, they compared the accuracy results in terms of the mean absolute error (MAE) and root-mean-square error (RMSE) for the developed applications, and the achieved results inferred that the convolutional neural network (CNN) with k-means algorithm had a significant percentage of minimizing in case of the RMSE.

Electricity cost significantly affects the stability of the electrical networks. Also, reaction times of power consumers and producers impact the stability parameter of smart grids. In [18], Wood presented a mathematical model for DSGC systems to demonstrate the demand control of smart grids via correlating the electricity cost to changes in the frequency of grids based on the time metrics of little seconds. The power demand-side production and consumption depending on analog time gauges were simulated, a data-corresponding machine learning algorithm was implemented, and the utilized variables were independent. Training the huge data with changes in their dimensions decreases the accuracy of the algorithm. In [19], Chen proposed a machine learning algorithm, with a principal component analysis approach [20] to minimize the dimensions of the utilized data for increasing the stability of the smart grids.

Several artificial intelligence techniques have been introduced for prediction of smart grid stabilities [2125]. In [21], Arzamasov et al. proposed a classification and regression trees (CART) algorithm for smart grid stability prediction. The authors utilized a four-node star architecture for a simulated DSGC system and achieved an overall accuracy of 80%. Aghamohammadi and Roggen[22] presented a decision tree (DT) algorithm with slightly simple architecture to predict smart grid stabilities. This algorithm was applied on the 39-bus power system. It utilized six samples of the dataset and achieved an overall accuracy of 90.3%.

Gupta et al. [23] presented a convolutional neural network (CNN) for a smart grid stability prediction that was tested on the IEEE 118-bus and 145-bus systems with an achieved accuracy of 89.22%. This work was evaluated using a variety of evaluation metrics. In [24], Zare et al. proposed a Bayesian rate (BR) algorithm for smart grid stability prediction. This algorithm was also applied to the IEEE 39-bus test system and reached an accuracy of 91.6%, but this algorithm consumed too much computational time for the training process. In [25], Chen et al. introduced an XGBoost algorithm using inertial sensors to predict a smart grid stability with a large number of data features. This algorithm was applied on a 39-bus power system and had a 97% accuracy. However, only one evaluation metric, namely accuracy, was utilized to evaluate the performance of the developed algorithm. Furthermore, real-time simulation of power systems can be used for different smart grids [2630].

Looking at the reviewed literature, one can argue that although a number of research studies have attempted to develop an accurate neural network for smart grid stability prediction, there are still improvements to be reached. In this paper, a neural network is proposed to predict smart grid stability with the overarching objective of increasing/improving the prediction accuracy of the neural network via a hyperparameter tuning method. The neural network is trained and tested on the dataset available in the Kaggle repository [31].

The main contributions of the paper are highlighted as follows:(i)Implementing an artificial neural network to predict the stability of a smart grid(ii)Achieving maximum testing accuracy of the neural network with a hyperparameter tuning method on a central processing unit (CPU)(iii)Analyzing the performance of the implemented neural network via various evaluation metrics depending on the utilized dataset(iv)Validating and enhancing the performance of the neural network by the k-fold cross-validation technique.

The paper is organized as follows: Section 2 presents a theoretical background related to the multilayer perceptron (MLP) artificial neural networks. Section 3 describes the proposed neural network, utilized dataset, and evaluation metrics utilized with the proposed neural network. Section 4 shows the experimental results. Section 5 discusses the results. Finally, a conclusion from the work is drawn in Section 6.

2. Theoretical Background of Multilayer Perceptron Artificial Neural Networks

MLP is a type of feed-forward neural network; it is most widely utilized in ANN architecture, trained with backpropagation error, and developed by Agatonovic-Kustrin and Beresford [32]. Figure 2 shows an example of an MLP neural network architecture. It is built by an input layer, a hidden layer, and an output layer [33]. The function of the input layer is to provide data from an external source, then these data are transferred to a hidden layer, which are multiplied with weights, and then it passes to the output layer to generate final signals [34]. The prediction ability of the ANN totally depends on the hidden layer, which contains neurons. In the ANN, a number of data features given to the input layer and multiplied with weights are added to bias functions and then a nonlinear activation function is applied, as shown in equation.where represents the weight between the hidden and input layers, ak represents the hidden layer output, bk is the bias function for the current layer, and ReLU is the activation function of the neuron, which is utilized in neural networks training, as it minimizes the error gradient and vanishing. Furthermore, ReLU has higher speed than other activation functions [35]. It is calculated via the following equation:

The output layer is utilized for the MLP architecture of the neural network. The output layer is calculated using equation (3). The MLP neural network process is repeated until the last weight and input, as shown in Figure 2.where represents the weight between the output and the hidden layers, yk represents the predicted output, ak−1 is the output from the previous layer, and σ is the sigmoid activation function. It is preferred for applications that have binary classification. This function is calculated using the following equation:

3. Proposed Neural Network

Figure 3 illustrates the proposed neural network architecture. It consists of an input layer, three hidden layers, and an output layer. The input layer has 288 neurons with 12 features. Firstly, a hidden layer is applied to each feature of input data, this layer uses a ReLU activation function to capture data features. This hidden layer has 288 neurons, followed by another hidden layer with 24 neurons with a ReLU function, then followed by a final hidden layer that has a configuration of 12 neurons, and also uses a ReLU function. The final hidden layer is added to enable the neural network to identify more features that might have been missed in the previous hidden layers. A dropout is used after the first hidden layer with 25% drop rate from its neurons to tackle the problem of overfitting [36]. Finally, the output layer has one single neuron, it utilized a sigmoid activation function to reduce the output for 2 classes [37]. This neural network is built using Keras framework. The advantages of the proposed neural network are as follows: it has simple architecture, it consumes less time during the training phase, and it has high performance to predict a smart grid stability.

In this neural network, an Adam optimizer algorithm is used [38]. This algorithm, which determines the optimum weights for this neural network, minimizes the errors, and also maximizes the training accuracy [39]. A loss function, namely binary cross-entropy, is utilized to measure the error between the prediction and the true values [40]. This neural network is trained based on a batch size of 100 and training epochs of 50. This neural network has total trainable parameters of 94,225. Table 1 shows a summary of the implemented layers of the neural network.

3.1. Data Description

The dataset utilized for the prediction is from the Kaggle repository [31], it has 60,000 samples of two grid stabilities stable, and unstable, and the sample percentage for each class are 36.2%, and 63.8%, respectively. The dataset has results which are collected from grid stability simulations executed on a four-node star network architecture, as shown in Figure 4 [21]. This architecture has a synthetic nature. It consists of one energy source, which is a centralized generation node to supply energy to three consumption nodes. The dataset has twelve mainly predictive features/information related to the stabilities of the grids’ stabilities: four features for the nominal power produced or consumed by each participant “p1, p2, p3, and p4,” which have values from −2.0 to −0.5, where the overall power produced “p1” from the supplied node equals the overall power consumed from the three consumer nodes, i.e., p1 =  − [p2 + p3 + p4]. Other four features for the reaction time of each network participant “tau1 to tau4,” real values range of these features from 0.5 to 10, tau1 represents the supplier node, while “tau2 to tau4” represent the three consumer nodes. Also, four features for the energy price elasticity coefficient for each network participant “g1 to g4,” which have a real value within a range of 0.05 to 1.00. The g1 corresponds to the supplier node, while “g2 to tau4” represent the three consumer nodes. In addition, the dataset has two dependent parameters: “stab” and “stabf,” when the “stab” has a positive value, the DSGC system is linearly unstable. However, if the “stab” has a negative value, the system is linearly stable. The “stabf” represents a binary label whether stable or unstable.

The dataset is split into a training set (75%) and a test set (25%), the test set utilized to evaluate the proposed neural network. It is split via Scikit-learn framework. The utilized dataset is chosen, as it has sufficient data with a sample size of 60,000 observations to train the proposed neural network. The training set receives 45,000 observations, while the testing set accommodates the reminder 15,000 observations. A probability sampling approach is used for a random distribution of the dataset. This approach provides a strong training process for the neural network and so enhances the performance of the neural network [41]. There is a relationship between the consuming time of training process and the accuracy of the neural network; it is the amount or size of the utilized dataset.

3.2. Evaluation Metrics

After the training process, an evaluation phase is conducted to analyze the performance of the proposed neural network using various metrics [4244]. These metrics include accuracy, recall, precision, and F1-score. Each metric depends on statistical values which are a result of a confusion matrix: true negative (TN), false positive (FP), true positive (TP), and false negative (FN). TN represents an outcome where a neural network correctly predicts the negative class, and FP means a neural network wrongly predicts the positive class.

TP represents an outcome in which a neural network correctly predicts the positive class, and FN presents a neural network wrongly predicting the negative class. Also, the confusion matrix is utilized to obtain the ability of a neural network to predict two classes accurately with the neural network using the testing dataset to compare a true class with an output predicted class.

The first metric, accuracy, represents the ratio of correct predictions to the total predictions of the testing dataset. The accuracy is calculated via the following equation:

The second metric is the recall, the ratio of accurately classified positives of a specific class to the total number of true class activities in the test dataset. From equation (6), recall can be calculated, it is also known as sensitivity.

The third metric, precision, is the ratio of correct predictions of a specific class activity to the total predictions of the same class in the testing dataset. Precision is calculated using the following equation:

The fourth metric is F1-score, which is the average of the recall and precision with a weight of 2, see equation (8). F1-score is also known as the balanced F1-measure. It takes both false negatives (FN) and false positives (FP) into calculation. So, F1-score is a more beneficial metric for an evaluation than the accuracy metric. The best possible value of all four metrics is 100%, and the worst is 0%.

Also, an evaluation metric utilized for the neural network is the area under the ROC curve (AUC), which is described as the integral of the false positive rate (FPR) multiplied by the true positive rate (TPR). AUC is calculated via equation (9). This metric value is permanently between 0 and 1. A high value of AUC implies a neural network is capable of distinguishing between classes of smart grid stability. So, the neural network with the largest area under the ROC curve is the best neural network for classification.

TPR is calculated in equation (10), while TPR is obtained from equation (11). The TPR is the ratio of the number of true positives (TP) to the sum of true positives and false negatives (TP + FN). The FPR is the ratio of the number of false positives (FP) to the sum of false positives and true negatives (FP + TN). FPR is also known as 1-Specificity.

The utilized evaluation metrics “accuracy, recall, precision, F1-score, and area under the curve” are selected due to their effectiveness in evaluating and analyzing the neural network performance [45].

4. Experimental Results

Using Python programming language, the proposed neural network is experimentally implemented, with a Jupyter Notebook environment. The neural network is executed on a personal computer (PC) with an Intel Core i7, a 2.2 GHz processor, and an operating system “Microsoft Windows 10,” and a RAM memory of 16 GB. Figure 5 illustrates the two curves for testing and training accuracy of the neural network. The training curves are also known as learning curves. The pink curve is training accuracy, which continuously changes and reaches a maximum value of 97.51% after 50 epochs. The green curve represents the testing accuracy, which starts from 74.89% and reaches 97.36% after 50 epochs.

Figure 6 demonstrates the curves of loss rate for the neural network depending on the testing and training sets. With increasing number of epochs, the loss rate continuously decreases. For the training set, the loss rate reaches 0.0623 after 50 epochs, while the rate loss for the test set starts at 0.3707 and declines to 0.0619.

Figure 7 shows the confusion matrix obtained from the neural network. This matrix predicts labels, which are compared to true labels in the testing dataset. The diagonal values of the matrix mean the accuracy of the prediction, values above and below the diagonal show errors that occurred. Here, the matrix detects data of 3835 and 2046 as true positives for the two classes: unstable grid and stable grid, respectively.

Figure 8 presents the normalized confusion matrix for the neural network. This matrix has a prediction accuracy of 0.98 for two classes—unstable grid and stable grid, with only 0.02 as prediction errors for the classes. It is noticeable from this matrix that the neural network performs so well with minimal errors.

A classification report of the evaluation metrics is presented in Table 2. It includes the recall, precision, and F1-score of the neural network, to evaluate its relative performance of the utilized dataset. In this report, for the unstable grid class, the precision, recall, and F1-scores were 98.92%, 98.03%, and 98.47%, respectively. For the stable grid class, the precision, recall, and F1-scores were 96.37%, 97.99%, and 97.17%, respectively. The macroaverage precision, recall, and F1-scores are 97.64%, 98.01%, and 97.82%, respectively. The weighted average precision, recall, and F1-scores for the neural network are 98.03%, 98.02%, and 98.02%, respectively. The macroaverage is obtained from computing an evaluation metric independently for the two classes and then finding the average.

ROC and precision-recall curves are illustrated in Figures 9 and 10. These curves are probability curves utilized to evaluate the neural network. Figure 9 demonstrates the ROC curves for the neural network, and we notice the area under the curve values for two classes is 1.00. Therefore, the microaverage ROC curve area is 1.00. This result means that the neural network achieves high performance. Precision-recall curves introduce the precision rate as a function of recall rate. Figure 10 shows the precision-recall curves for the neural network for the two classes. In this figure, the lowest area is the class 0 “unstable grid,” which achieved an area of 0.996 under the precision-recall curve. The highest value is for class 1 “stable grid,” which achieved an area of 0.997 under the precision-recall curve. Thereby, the microaverage precision-recall curve area is 0.997. This value is obtained from the area summation of the two classes “class 0 and class 1” divided by the class number (e.g., here are two classes).

The precision-recall and ROC curves are comprehensive metrics, which consider all statistical values “TN, TP, FN, and FP”; and they are utilized in the evaluation of the proposed neural network. In addition, both curves enable easy and instant visual diagnosis of the neural network behavior. These curves are also based on the area parameter, where a more feasible test can be achieved by a greater area, and the areas under these curves are utilized to compare the usefulness of tests.

Figure 11 illustrates the correlation matrix of the utilized dataset features. It reveals a relationship between data features with the selected dependent variable and displays distribution patterns. In this figure, there are twelve predictive features and two dependent parameters. So, this matrix is based on 14 correlated parameters, three parameters for the power consumed “p2, p3, and p4” and one for the power produced “p1,” four parameters of the reaction times “tau1, tau2, tau3, and tau4,” and four parameters of the energy price elasticity coefficient “g1, g2, g3, and g4,” and two parameters as dependent variables “stabf” and “stab.”

“stabf” represents the label for the dataset. In this matrix, it is noticeable that the “stab” parameter is dropped from the dataset and the “stabf” parameter is selected. This matrix proves the correlation between each numerical feature and the dependent parameter. It shows the correlation between the selected dependent parameter “stabf” and numerical features. Also, it is not difficult to see the average correlation between the power produced “p1” and the sum power consumed “p2, p3, and p4.”

Table 3 illustrates the performance of the proposed neural network via the k-fold cross-validation technique. In this technique, the dataset is divided into 5 equal partitions (one partition for validation and four partitions are used for training), where k denotes the number of the partitions and equals 5 in this case. The neural network is repeatedly trained five times using different partitioning of the dataset, with epoch numbers of 50 is chosen. According to this division, the average results of accuracy and loss rate for the neural network are 98.47% and 0.0384, respectively. Therefore, the proposed neural network has the high performance using 5-fold. Furthermore, the k-fold cross-validation technique enhanced the neural network performance and avoided the biasing for the performance results using a convenient division of the testing and training dataset.

Optimizers are utilized to calculate network parameters that affect neural network training and the output, in order to reach the optimal value, therefore reducing the loss function. It is the pillar of the neural network training. So, it is essential to select a convenient optimizer to train the neural network. Figure 12 shows three optimizers: Adam, Nadam, and RMSprop, which are experimentally tested to verify the network performance. It is clear that the neural network, which is trained by the Adam optimizer, has the best fitting effect and the fluctuation of the Adam curve is more stable. Thus, the Adam algorithm is utilized as the optimizer for training the proposed neural network.

So, more neurons make the proposed network more complex and have deeper features in the learning/training process. However, it also increases the neural network parameters, which need sufficient memory. Thus, it is important to select a suitable number of neurons. Figure 13 illustrates the total parameters and accuracy of the neural network with a varying number of neurons of the first hidden layer. It is clear that with the increasing number of neurons, the neural network parameters extend from 11,593 to 94,225. The accuracy of the neural network does increase correspondingly. Accuracy reaches 97.36% when the number of neurons of the first hidden layer is selected as 288, which outperforms when the number of neurons is 24 by 0.68%. However, the total trainable parameters of the neural network increase by more than 712%.

5. Discussion

The results illustrate that the proposed neural network has low loss rate and high accuracy when training and testing. Results from the ROC curves, confusion matrices, and precision-recall curves illustrate that an accurate prediction of smart grid stability can be achieved with the neural network.

Figure 5 presents the performance of the proposed neural network in terms of the accuracy of testing and training using the utilized dataset. Figure 6 shows the performance of the proposed neural network in terms of the loss rate achieved 0.0619. Figure 12 illustrates the effects of utilizing different optimizers on the performance of the neural network. Figure 13 shows the effects of neurons’ number of the first hidden layer on the performance of the neural network. Figures 7 and 8 illustrate error rates across the two classes and demonstrate that the neural network performs well.

Table 2 introduces a classification report of the neural network in terms of weighted average recall, precision, and F1-scores, which are 98.02, 98.03%, and 98.02%. The microaverage area under the ROC curve is 100%, and the area under the precision-recall is 99.7% for the neural network for the two classes, which means an extremely high performance. Also, Table 3 shows the performance in terms of the k-fold cross-validation technique.

Grid stability prediction is a very important issue and several works have been performed in this scope. Table 4 introduces a comparison of previously published works and the accuracy achieved by the proposed work. It is not so difficult to see that the accuracy achieved by the proposed neural network for predicting grid stability, 97.36%, is better than the prediction techniques referred to in [2125].

The high performance achieved can be attributed to the fine-tuning of the neural network’s hyperparameters, the training epochs, optimizer type, loss function, dropout rate, activation functions, batch size, and the number of neurons utilized in the hidden layers of the proposed neural network. When the number of training epochs and batch size were set to 50 and 100, respectively, and using a sigmoid activation function with neurons’ number of the first hidden layer adjusted to 288 neurons, the neural network achieved a testing accuracy of 97.36%. However, when the training epochs were reconfigured to be 30, the batch size was changed to 80, with the same activation function, and the neurons number of the first hidden layer tuned to be 200 neurons, the neural network testing accuracy reached only 96.89%. So, the parametric settings of these hyperparameters can strongly enhance the results.

Furthermore, the highest possible performance of the proposed neural network was reached when the parameters were set to training epochs of 50 with a 100 batch size, the Adam optimization algorithm is used, and a binary-entropy loss function is implemented. The hyperparameters of the proposed neural network are tuned using the GridSearchCV method, which automatically computes the optimum values of the hyperparameters to achieve better performance of the proposed neural network.

6. Conclusion

This paper has proposed an implementation of a neural network for prediction of smart grid stability. The utilized dataset is taken from simulations of DSGC systems. Experiments carried out to test the accuracy of the proposed neural network achieve test loss rate of 0.0619, test accuracy of 97.36%, and training loss rate of 0.0623. Also, the neural network has a training accuracy of 98.23%.

The confusion matrix, recall, precision, F1-score, and ROC curves are described to allow evaluation of the neural network’s performance. The proposed neural network has a weighted average recall (98.02%), while the achieved F1-score and precision are 98.02% and 98.03%, respectively. The microaverage area under the precision-recall curve is 99.7% for the proposed neural network. Finally, the area under the ROC curve is 100% for the two classes of this network.

The hyperparameters of the neural network, optimizer type and activation functions, loss function, the number of training epochs, batch size, dropout rate, and the number of neurons for the utilized layers in the proposed neural network were found to significantly affect the accuracy of the proposed neural network, and high performance achieved is highly depended on the optimal settings applied.

In addition, the performance of the neural network is evaluated in terms of the accuracy, recall, precision, and F1-score via the k-fold cross-validation technique.

Therefore, referring to smart grids, this neural network provides an accurate tools to predict grid stability as a new vision for the simulated DSGC systems. In the future, one could also build a new neural network to enhance the performance of predicting grid stability. The proposed neural network can be implemented with more datasets, and the performance of training can be compared with a graphics processing unit (GPU) environment. In addition, one could use a dataset from DSGC simulations and have input parameters with alternative values rather than the utilized fixed values.

Data Availability

The data used to support the findings of this study are available from the corresponding author on request.

Conflicts of Interest

The authors declare that they have no conflicts of interest.