A Nonintrusive Load Monitoring Method for Microgrid EMS Using Bi-LSTM Algorithm

Nonintrusive load monitoring in smart microgrids aims to obtain the energy consumption of individual appliances from the aggregated energy data, which is generally confronted with the error identification of the load type for energy disaggregation in microgrid energy management system (EMS)./is paper proposes a classification strategy for the nonintrusive load identification scheme based on the bilateral long-term and short-term memory network (Bi-LSTM) algorithm./e sliding window algorithm is used to extract the detected load event features and obtain the load features of data samples. In order to accurately identify these load features, the steady state information is combined as the input of the Bi-LSTMmodel during training. Comprising long-term and short-term memory (LSTM) network and recurrent neural network (RNN), Bi-LSTM has the advantages of stronger recognition ability. Finally, precision (P), recall (R), accuracy (A), and F1 values are used as the evaluationmethod for nonintrusive load identification. /e experimental results show the accuracy of the Bi-LSTM identification method for load start and stop state feature matching; moreover, the method can identify relatively low-power and multistate appliances.


Introduction
e advancement of nonintrusive load monitoring (NILM) is hastened by the ever-increasing requirements for smart microgrid power utilization and demand side management [1]. e long-term and short-term memory NILM has disaggregated real-time energy consumption information with the load detection module installed at the microgrid EMS power input, which is one approach of demand-side management strategies in the smart grid [2]. Compared with traditional intrusive load monitoring, it has several significant advantages such as low cost, excellent data integrity, easy installation, and good practicability [3,4].
is has become a significant direction for researchers in the microgrid energy management system (EMS). e NILM process mainly includes data acquisition and processing, event detection, features extraction, and load identification.
ere are various methods for feature extraction [5] and load identification [6], including supervised classification methods [7], unsupervised clustering methods [8], and optimization methods [9]. Among them, the deep learning algorithms are widely used in the field of load identification [10,11]. In particular, a low complexity unsupervised NILM algorithm was presented in [12], which has outperformance for event detection compared with recent existing work for unsupervised NILM considering common metrics. A practical solution for nonintrusive type II load monitoring based on deep convolutional neural networks was provided in [13]. Further, three new graph-based semisupervised multilevel load monitoring algorithms were studied in [14,15], which only needs a small sample of observed power signals annotated with active appliances. ey tackled the NILM by applying a novel graph signal processing (GSP) into both the physical signal level and data level. Additionally, a deep learning framework based on a combination of a convolutional neural network (CNN) and LSTM was proposed in [16], in which the proposed hybrid CNN-LSTM model used CNN layers for feature extraction from the input data with LSTM layers for sequence learning. Although the current identification algorithms for multistate load and low-power load identification have achieved certain recognition performants, their identification of load power and performance improvement still needs further research.
Alternatively, feature construction is also considered as the key step to achieve load monitoring technique. For example, a method based on the dynamic time warping (DTW) algorithm and template library waveform was proposed [17] to cope with the existing problems with the steady load characteristic value method and the superposition of the steady-state waveform of domestic load. In references [18,19], researchers employed short-time Fourier transform feature extraction and LSTM auto encoder neural networks-based classification and fault detection on DC pulsed load monitoring to demonstrate the effectiveness of nonintrusive load monitoring. In ref. [20], the neural network model was developed to recognize steady-state parameters extracted from low-frequency sampling data, such as real power, current, impedance, and admittance variables. In reference [21], a new algorithm is proposed to classify events of appliance states based on modification of the cross entropy (CE) method, which relies on low-rate sampling of the active power. Nevertheless, this method cannot cope with the identification of low-power appliances.
In this paper, a nonintrusive load monitoring scheme based on Bi-LSTM algorithm is proposed to improve the performance of the nonintrusive load identification. e steady state features are constructed by the active power, reactive power, and the current harmonics features. It is applied to the load identification by combining the steady state information at the beginning and the end of the load state to construct the features data. en, the nonlinear mapping is carried out to the output layer for the load identification. Besides, in order to address the problem of multiload feature identification, a load start state feature matching method based on the Bi-LSTM model is adopted, and the output of the optimal matching item in the Bi-LSTM model is taken as the final identification result. e rest of the paper is organized as follows. Section 2 introduces load features construction, which contains both load power signatures and time domain features, followed by an extraction method of load features based on the sliding window algorithm. en, an overview of the Bi-LSTM algorithm model and load identification scheme based on the Bi-LSTM model is described in Section 3. In Section 4, load feature of the microgrid EMS is trained and tested by recurrent neural network including (RNN), LSTM, and Bi-LSTM for comparison, as well as the verification experiment of identification method of load start and stop state features matching is carried out. e conclusions are drawn in Section 5.

Load Features Construction
In load feature construction, the power features and time domain features are mainly considered, which will be discussed in detail.

Power Feature Construction.
Among the existing load features, the active power P is considered as the widely used load features since it undergoes an obvious change when the load turns on/off status switch [22]. Similarly, the reactive power Q also plays an important role in determining the type of appliances, that is, inductivity, capacitance, or resistance of electrical devices. In order to obtain these features from the electrical entrance, the P and Q are calculated by using the transient voltage and current.
Let v (t) and i (t) be the transient voltage and current at time t, and P and Q can be then defined as follows: where T represents a period of the voltage wave.
To get more performants for identification, it is necessary to find another type of features. In this paper, the series of the obtained active power and reactive power are listed as follows: where n 1 and n 2 are the ranks belonging to active power and reactive power, respectively. ese data are ranked in a plain sequence. Furthermore, to distinguish different loads effectively, especially for the loads with small active power (usually smaller than 100 W), unequal interval segmentation is adopted. e power variation of these loads is subtle that makes difficulty for load identification. us, a statistic of load signatures in load database is adopted to get a more accurate interval of power [23]. e P and Q distribution coming from the dataset is illustrated as rectangles with different colors in Figure 1, where load 1 to load 11, respectively, represent bedroom appliances, basement plugs, cloth dryer, cloth washer, dining room plugs, dish washer, network equipment, fridge, heat pump, TV/PVR/AMP, and wall oven. As seen, several loads are concentrated when P belongs to 0-100 and Q belongs to 0-20. is indicates that loads in this range need to be segmented more intensively. Hence, the segmentation point p i is set as follows: where r (p i ) is the kernel density of p i , {p i } (i � 1∼n) is a set of power points, q is the window width of the kernel density estimation function K(·), and ε is the threshold. According to equation (3), the point where the power signatures can be divided into two groups by the kernel density is the segmentation point. However, for the complicated situation consisting of various loads, the features P and Q and their variation are not sufficient to identify load with similar electrical features. erefore, the following subsection selects time domain 2 Complexity features as dependable nonelectrical features for load identification.

Time Domain Feature Construction.
Time domain features are often treated as the potential load features [24]. To get all-round information about load features in time domain, this paper introduces the features of working time length and interval, working period, and holiday character.
(i) Working time length: For common microgrid loads, the working time length has almost regularity; i.e., it is an inner character to distinguish different loads [25]. Figure 2 illustrates the working time length counted for eleven loads as shown in Figure 1. It can be seen that most of the microgrid loads work for no more than 100 minutes in a day. A few loads work for over 1400 minutes. In addition, some loads have different working time lengths. erefore, to construct this type feature, the segmentation method is used as follows: where L denotes the length of working time, and m 3 are the amounts of ranks. (ii) Working time interval: Working time interval of loads can often reflect the users' energy behavior. Similarly, Figure 3 illustrates time interval of the same loads counted. Different color in Figure 3 shows the different load. It can be seen that most of loads are used in the daytime from 6 : 30 to 21 : 30, while, in the night during 21 : 30-6:30, some other loads work. us, the time interval in this situation can be generally divided into 9 segments for quantization. e divided segments are shown in Table 1. During 6 : 30-21 : 30, every two hours belongs to one part, and from 21 : 30 to 06 : 30 on the next day, it is divided only into 2 segments, including the late-night period (21 : 30-24 : 00) and the period before dawn (0 : 00-6 : 30).
(iii) Working periodicity: Generally speaking, some of loads often work with periodicity, such as a refrigerator. On the contrary, the working time of loads without periodicity is almost uncertain. us, to easily distinguish the two types of loads, the mark here is just used as T � {T 1 , T 2 } with nonperiodicity T 1 and periodicity T 2 .
(iv) Holiday character: Different behaviors of the users' routines lead to different frequencies of load usages. For example, the probability of using traditional household electronic will increase when it is on holiday, while the usage of loads for entertainment will decline when it is a weekday since the users go to work. us, it is a nonnegligible character in time domain. For convenience, this feature is defined as and F 3 denote loads that work every day, every weekday, and sometimes, respectively.
On these bases, load features can be detected and extracted to build the load features database, which will provide training samples. To this end, the load events detection and feature extraction method will be presented as follows.

Load Event Detection and Feature Extraction.
Load events often occurred by turning on or off the load, thus making electrical feature change. Generally, active power is the most significant since the load events happened [26]. e associated evolution curve seems like a step jump, indicating that the load event occurs. In order to obtain the feature, the sliding window algorithm is used to detect these changes and extract the feature through a different method. For time domain features, the load features are defined as follows: When a load event occurs, the distribution of observation changes. e following hypothesis test is made to see whether there exists a change:   Complexity whereμ 0 and μ 1 are divided into the average value of the observed quantities; σ 0 andσ 1 are the standard deviation of the observed quantities; τ is a positive integer to record the time of the load event. To be specific, the variation of the mean and variance increases as the sliding window algorithm contains the event occurrence point. us, it would be regarded as a load event if the variation of mean and standard deviation exceeds a certain threshold. e load steady state features have the advantages of easy acquisition and excellent repeatability [27]. However, the features of load running to steady state generally show volatility due to the fluctuation of voltage and current, which lead to different load steady state feature extractions [28]. In order to fully reflect the load operation process, this paper selects the steady state feature near the occurrence point of the load event. When the load event is detected, two steady states of the load event input and output are differentiated. Let a certain length of time series as load input events and cut events be feature vector V o and V c , and it can form a set of feature data samples e sliding window algorithm is then used to determine the changes in the active power of the load event detection, and the load event is then used to extract load steady state features, enabling the performance improvement of load identification.

Bi-LSTM Algorithm Model.
e load data collected by noninvasive equipment can be regarded as time series signals. Recurrent neural network (RNN) is an artificial neural network with nodes connected and memory function, which can recognize serialized information effectively [29]. e state is transmitted one-way after going in chronological order, which can only guarantee the forward transmission of information. e improved Bi-RNN scheme adds a hidden layer to the existing RNN model. By comparison, it separates each training sequence forward and reverse as two RNNs and connects the same output layer.
To avoid the problem of gradient disappearance and long-term dependence, we further improve the Bi-RNN model as Bi-LSTM model. In this model, multiple activated neurons are used as hidden layers to selectively save or forget long-term data to satisfy the long-term data dependence requirements. e fundamental of Bi-LSTM consists of two RNN models, where one RNN model trains the data from the forward direction and the other trains the data from the backward direction. e two models then connect the output layer in the Bi-LSTM. Figure 4 shows the structure of Bi-LSTM model, which is a combination of two unidirectional LSTM.
As seen in Figure 4, Bi-LSTM model hidden layer output vectors are marked asAandA′, respectively, participating in forward and reverse calculation. In forward calculation, the outputA t of the hidden layer is affected byA t−1 . When it calculates in reverse, the valueA t ′ of the hidden layer is affected byA t+1 ′ . Additionally, the activation function of Bi-LSTM model in Figure 4 is illustrated as follows: where g(·) and f(·) represent the output layer neuron activation function and the hidden layer neuron activation function, respectively.Vis the weight matrix from the hidden layer to the output layer in forward calculation, whereas Wis the weight matrix from the input layer to the hidden layer in forward calculation. Besides, Uis the weight matrix from the input layer to the hidden layer calculation, whereas V ′ is the weight matrix from hidden layer to output layer for reverse calculation. Moreover, W ′ is the weight matrix of the hidden layer at the first moment in reverse calculation, whereasU ′ is the weight matrix of the input layer to the hidden layer calculation in reverse.

Load Identification Scheme Based on Bi-LSTM Model.
e load identification scheme of Bi-LSTM neural network consists of training and identification stages. e significant step is to use the SoftMax function to map the data into the range [0, 1], which can be regarded as the probability that the sample data belongs to a certain class [30]. In the classification, cross entropy can represent the degree of proximity between the actual output and the expected output, which is used to calculate losses. In the training step, the neural network realizes the nonlinear fitting from input to output by adjusting the parameters of the weight matrix. Backpropagation through time (BPTT) method adjusts the weight matrix parameters along the gradient direction of error and makes the output results of the neural network approach to the actual results continuously [31]. Here, SoftMax function and cross entropy function [32] are used as the activation function and the loss function of neural network, respectively, in this paper. BPTT method is taken as a training algorithm to establish an identification algorithm model. e flowchart of load identification scheme is to detect load events, extract input, and cut out load features according to the time of load events, as shown in Figure 5.
In microgrid EMS, there is much electric equipment operating at the same time, and the collected steady-state data will contain the feature vectors of multiple electrical appliances, which is not conducive to identification. In this ... Hidden layer: Output layer: Figure 4: Bi-LSTM algorithm model. Complexity paper, a load start state feature matching method based on the Bi-LSTM model is adopted, as shown in Figure 6. As seen in Figure 6, the time of load event is first determined by load event detection, and the load characteristics of all input and cut out events are extracted. en, the input and cut-out features of the same appliance are matched as the input of the neural network model. A cut-out (input) feature and all other input (cut-out) features are fed into the Bi-LSTM model according to the combination for identification, and a combination with the highest output probability is taken as the best match.

Test Results and Discussion
is work selects eleven representative loads for the test from the microgrid EMS, including the traditional household loads and modern commonly used electronic loads. Without loss of generality, all loads with small power consumption and those with multistatus are selected for demonstrating the performance of our method. en, based on the above eleven representative loads, five typical loads are randomly selected to verify the experimental verification load start and stop feature matching principle.

Load Features Extraction of the Microgrid EMS.
e sliding window algorithm is used to extract the detected load event features and obtain the load features data samples from the microgrid EMS. e features in the method are constructed by the active power, reactive power, and the fifteen odd-even current harmonics features, which were selected as the input for neural networks.
e harmonic component of current can be obtained by fast Fourier transform.
In the load identification scheme for eleven different operating states in microgrid EMS, outputs can be considered as matching a load to the trained sets such that the neural network has outputs as listed in Table 2.
it is specified that each output is a probability value representing the probability that the input data belongs to a certain state. e value range is between 0 and 1, where 0 and 1, respectively, mean that the input data cannot and must belong to the state. e corresponding output state with the highest probability is regarded as the identification result of the input data.

Training Scenario I.
In this test, five-day load features data of the microgrid EMS are picked up for training. In each case, the loads used in the microgrid EMS are not directly illustrated. For example, one day of the active and reactive power curve of one day is drawn in Figure 7.
e labeled data are trained to obtain the probability of each load event by sliding window algorithm. e extracting results are shown in Figure 8. It can be seen that there are 3 loads with powers in the interval 0-30 W in Figure 8(a), 5 loads in 30-100 W in Figure 8 For verification of the proposed scheme, there are two neural networks for comparison by using the 5-day data for the test. e precision (P), recall (R), accuracy (A), and F 1 values are used as the evaluation indexes to train and test the RNN, LSTM, and Bi-LSTM neural network. e results of the average precision (P), average accuracy (A), average recall (R), and average F 1 of the three neural networks are listed in Table 3.
It can be seen from the four evaluation indexes of identification average precision (P), average accuracy (A), the average recall (R), and average F 1 given in Table 3 that the Bi-LSTM is better than RNN and LSTM. Moreover, Bi-LSTM shows higher computational efficiency and better performance in load identification. Besides, the errors in training and testing of the three neural networks are calculated, as shown in Figures 9 and 10. As seen, the error drop speed is the fastest training in Bi-LSTM scheme than others. At the end of the training period, the three kinds of neural networks finally tend to stabilize, but the Bi-LSTM does not fluctuate since the error drops smoothly, and the stability is reached faster.
Additionally, the error range of test samples for RNN, LSTM, and Bi-LSTM is, respectively, 0.02-0.08, 0.01-0.06,  and 0.01-0.03 according to Figure 10. It can be seen that the error Bi-LSTM in the test is smaller and more concentrated. Figure 11 shows the result of load identification. As time increases, the accuracy of the Bi-LSTM and LSTM neural network algorithm identification models increases rapidly, while the accuracy of the RNN neural network algorithm identification model fluctuates greatly. By comparison, the accuracy of the Bi-LSTM neural network algorithm identification model is about 10% larger than that of the LSTM. erefore, the Bi-LSTM training error converges faster, and the identification error is smaller at the same training times.
Additionally, the proposed scheme combining sliding window algorithm and Bi-LSTM shows the satisfactory performance for load identification in these cases.

Training Scenario II.
In this test, based on the above eleven representative loads, five typical loads are randomly selected to train. Turn on and off each load in turn, considering the interval between two starts and stops greater than 50 sampling points. Each sampling point has a time interval of 0.02 seconds. Figure 12 shows the power curve of    five typical loads. As seen, the proposed load identification scheme can detect the load starting and ending state, and it has a good adaptability to small disturbances. e results of the on and off event detection are shown in Tables 4 and 5.
Five groups of load samples were obtained by combining load features, which are fed into the Bi-LSTM model according to the combination for identification, and a combination with the highest output probability is    taken as the best match. e test results of load matching are shown in Table 6. As seen, the identification results are almost right, and the probability is greater than 99%. To a certain extent, the proposed experimental verification load start and stop feature matching scheme can effectively match and identify load events.

Conclusions
On account of cost-effectiveness, nonintrusive load monitoring provides intelligent demand side management and power utilization for microgrid EMS. is paper proposes a Bi-LSTM based nonintrusive load monitoring method, which considers both the power features and time features. To obtain load features from the load events, the sliding window algorithm is adopted in our method. e load features, constructed by the active power, reactive power, and the features of 15 odd-even current harmonics, are selected as input variables of neural network. Besides, the precision (P), recall (R), accuracy (A), and F 1 values are used as the evaluation indexes to train and test the RNN, LSTM, and Bi-LSTM neural network algorithm. And then, experiments on dataset of the five-day microgrid EMS load features verify the proposed load identification performance. Five typical loads are randomly selected in the experiments to verify the proposed main results.
Data Availability e training data results used to support the findings of this study are included within the article. e raw single-device load data and training data used to support the findings of this study are included within the supplementary information files. All data types used to support the findings of this study are available from the corresponding author upon request.   10 Complexity