Electricity safety perception method, equipment and medium based on random forest algorithm
Through the low-voltage customer power safety perception method based on the stochastic forest algorithm, combined with the long-term and short-term memory artificial neural network to calculate the zero-crossing retention probability index of fault arcs, the problems of inaccurate eigenvalues and overfitting in the existing technology are solved, and the problem of inaccurate eigenvalues and overfitting is achieved. Accurate judgment of fault arcs, leakage and short circuits improves the power safety of low-voltage users.
Patent Information
- Application Number
- CN202111634082.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2041-12-29
AI Technical Summary
The existing intelligent perception method for low-voltage customer electricity safety has inaccurate feature values, limited detection indicators, difficulty in accurately determining fault arcs, leakage and short circuits, and the probability of overfitting is high, resulting in low robustness and low accuracy of the model.
The power safety perception method based on the random forest algorithm is adopted. By collecting current data and extracting characteristic indicators such as current peak-to-peak, amplitude, integral and variance, power information entropy, etc., it is input into the random forest model, and the output of each decision tree is used. The value is averaged for judgment, and combined with the long and short-term memory artificial neural network to calculate the probability index of fault arc zero-crossing and retention, to achieve a comprehensive judgment of fault arc, leakage and short circuit.
It improves the accuracy and reaction time of fault arc judgment, reduces the risk of overfitting, enhances the generalization ability and accuracy of the model, and ensures the power safety of low-voltage users.
Smart Images

Figure CN114580829B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electricity safety monitoring, and in particular to an electricity safety perception method, device and medium based on a random forest algorithm. Background Art
[0002] With the advancement of science and technology, various new technologies continue to emerge, the application of electrified products has been greatly popularized, and various low-voltage electrical appliances have spread to all areas of people's production and life, but this has also brought certain safety hazards. Electrical safety accidents caused by aging or improper configuration of electrical lines have an increasing trend year by year, and low-voltage fault arcs are one of the main causes of electrical fires. Low-voltage arc faults in the form of short circuits in low-voltage distribution devices still exist, and the losses caused are very serious, posing a huge hidden danger to people's lives and property safety. In addition, gas explosion accidents caused by leakage have caused serious casualties to workers. Therefore, there is an urgent need for a method suitable for low-voltage customer electricity safety perception to detect fault arcs, leakage and short circuit faults in low-voltage systems in real time.
[0003] Fault arc is a phenomenon of gas ionization discharge caused by carbonization path or point contact. When the insulation material is aged and damaged or the line is overloaded and heated to generate leakage current, a carbonization path will be formed on the surface, thereby generating an arc. Arc detection technology is a technology that extracts features from the original current data (normal working state and fault state), uses it as the condition for arc recognition and the input of the calculation model, and identifies whether there is an arc in the line through the calculation model (after training with a training set). Common artificial neural network models include BP neural network model, convolutional neural network, pulse neural network, etc. Leakage protection refers to when the phase line of the protected line is directly or through an unexpected load connected to the ground, and a residual current with an approximate sine waveform and a slowly changing effective value is generated. When the current is greater than a certain value, the protector cuts off the line to play a protective role. Currently commonly used means of leakage protection: using a leakage protector to sense the residual current in the line, leakage protection based on fault characteristic values, etc. When the insulation of the electrical appliances or distribution lines in the electrical control circuit is damaged, the load is short-circuited, or the wiring is wrong, a short-circuit fault current will be generated. Short circuit protection requires cutting off the power supply within a very short time after a short circuit fault occurs.
[0004] At present, the common methods for intelligent perception of low-voltage customer electricity safety include: low-voltage arc detection technology based on convolutional neural network, and leakage protection method based on PSO-VMD. The principle and steps of the method are as follows:
[0005] 1. Low-voltage arc detection technology based on convolutional neural network
[0006] Principle: Convolutional neural networks have three typical characteristics, namely sparse connection, weight sharing, and translation invariance. During the convolution operation, the nodes of the convolution layer are only connected to some nodes of the previous layer and are only used to learn local features. This is sparse connection. Sparse connection greatly reduces the number of parameters and computational complexity required by the network. In order to further reduce the number of parameters, all nodes in the same convolution layer share parameters, which is weight sharing. Another feature of convolutional neural networks is translation invariance. For example, in image classification, the classification target moves the same distance in the same direction in the image, and the classification result remains unchanged. This is mainly due to the translation invariance of the convolution operation, that is, the target is translated, and the expression of the target on the feature map is also translated.
[0007] step:
[0008] ① Collect current data: Use current transformer to collect current data through the built arc experimental platform.
[0009] ② Data preprocessing: select the half-cycle current signal as a fault arc data sample, and use the time window data extraction method. In order to speed up the model training speed and improve the model accuracy, the collected current data is normalized.
[0010] ③ Divide the experimental data set: Construct a data set containing single-load samples and multi-load samples. For a single load, collect samples when it is in normal operation (negative samples) and samples when a fault arc occurs (positive samples). For multiple loads, only samples when it is in normal operation are collected, and all loads are randomly combined during collection.
[0011] ④ Fault arc current feature extraction: The time domain features of the half-cycle current signal, the frequency domain features extracted by FFT, and the signal detail features extracted by WT are used to form a 19-dimensional feature vector, which is then input into the classification model.
[0012] ⑤ Selection and optimization of classification model: artificial neural network is selected as the classification model, and each arc current feature extracted is normalized, and the feature vector after feature normalization is used as the input of artificial neural network. The cross entropy loss function is used as the objective function of artificial neural network.
[0013] ⑥ Design convolutional neural network: Design a fault arc detection model based on convolutional neural network, and use residual connection, void convolution, multi-scale feature fusion and other technologies to optimize the network model.
[0014] ⑦ Network parameter optimization: The Adam algorithm is used to optimize the network parameters. To avoid overfitting, a dropout layer is added to the network, and the early stopping method is used during training.
[0015] 2. Leakage protection method based on PSO-VMD
[0016] principle:
[0017] VMD is an adaptive multi-component signal decomposition method that can decompose complex signals composed of multiple frequencies into several eigenmode components. The VMD decomposition process mainly consists of two parts: the construction and solution of the variational problem. When the VMD algorithm decomposes the signal, the number of decomposed modes K and the penalty factor Two parameters need to be set in advance, where K is the number of modal components obtained after decomposition. is the factor affecting the bandwidth of the modal component. The larger the modal component, the smaller the bandwidth. The smaller the modal component, the larger the bandwidth. For the setting of these two parameter combinations, most predecessors use artificial settings based on experience, which has a great impact on whether the parameter combination is optimal. Therefore, the setting of the VMD parameter combination affects whether the useful information of the signal can be accurately extracted. In order to reduce the adverse effects that may be caused by artificial selection of parameters, the particle swarm optimization algorithm is used to optimize the VMD parameter group. The PSO algorithm is similar to the genetic algorithm. It is an optimization algorithm through iteration. The system initializes a set of random solutions and searches for the optimal solution through continuous iteration. Compared with the crossover and mutation of the genetic algorithm, the particle swarm optimization algorithm is a process in which particles search for the optimal solution through the optimal particles in the solution space.
[0018] step:
[0019] ① Initialize the particle swarm;
[0020] ②Update the position of particles;
[0021] ③Find the corresponding integer position;
[0022] ④ Perform VMD processing on the signal at different particle positions and calculate the fitness value minE of each particle p For each particle, if the fitness value of the particle is better than the original individual extreme value P best , set the current fitness value to the individual extreme value P best ;
[0023] ⑤ According to the individual extreme value P of each particle best Find the global extremum g best ;
[0024] ⑥Update the position of the particle again;
[0025] ⑦ When the iteration stop condition is reached, stop the program.
[0026] In the above scheme, the need to screen the eigenvalues increases the computational complexity of the model and the memory space occupied, which slows down the fault detection speed. In addition, there are large differences in the importance of eigenvalues, and feature evaluation is required. However, current technology still has difficulties in evaluating the importance of eigenvalues, which reduces the robustness and generalization ability of the intelligent perception model.
[0027] At the same time, due to the subjectivity in constructing detection indicators and the limitations of methods such as threshold judgment, the anti-interference ability is weak, and misjudgment or missed judgment may occur during fault detection, resulting in a decrease in the accuracy of identifying safety issues for low-voltage users.
[0028] In addition, the above schemes usually detect arc faults based on the physical characteristics and waveform characteristics of the arc and the setting of the slope setting threshold or the length of time the current stays within a certain range near zero crossing. However, such methods are too idealistic and do not fully conform to the actual situation. Such methods will reduce the accuracy and efficiency of fault detection and fail to make timely and accurate judgments on arc faults.
[0029] Finally, since the algorithm model has only one output, the probability of overfitting increases.
[0030] Therefore, in summary of the above solutions, in the traditional AI-based low-voltage customer electricity safety intelligent perception methods, there are often problems such as weak model generalization ability, easy to fall into local extreme values during learning, and difficulty in feature importance evaluation and selection. As a result, the model has low robustness, the training process is prone to underfitting, and the accuracy of identifying safety issues for low-voltage users is low.
[0031] In the arc detection problem, the "zero-crossing retention" phenomenon is a significant feature of the fault arc. However, how to quickly identify the occurrence of the "zero-crossing retention" phenomenon to quickly detect the fault arc has become a technical problem. Most traditional methods are to set a slope setting threshold or judge the length of time the current stays within a certain range near zero to achieve the discrimination of the "zero-crossing retention" phenomenon. However, in actual situations, the slope value of the "zero-crossing retention" interval is not absolutely zero. After amplification, there is still a certain value of the slope, and different loads have different "zero-crossing retention" times, and their slopes are also distributed in a certain range. Therefore, using a set slope value or a set zero-crossing time length value to define the "zero-crossing retention" phenomenon will produce a large deviation. Summary of the invention
[0032] In order to solve the technical problems of inaccurate feature values, limited detection indicators, difficulty in accurately judging fault arcs, and high overfitting probability in the current intelligent perception scheme for power safety of low-voltage customers, the present invention provides a comprehensive model that does not require feature screening and integrates fault arc, leakage, and short circuit judgment. The model aims to quickly perceive and judge the occurrence of fault arcs, leakage, and short circuit phenomena, improve the accuracy of low-voltage user fault perception, and ensure the safety of life and property of low-voltage users. It is a method, device, and medium for power safety perception based on a random forest algorithm.
[0033] In order to achieve the above technical purpose, the technical solution of the present invention is:
[0034] A method for electricity safety perception based on random forest algorithm includes the following steps:
[0035] Step 1: Collect power consumption data and extract current peak-to-peak value, current amplitude, current integral and variance, current peak value, current power information entropy, current signal proportion of different frequency bands, current waveform factor, current peak index, current pulse index and fault arc zero crossing retention probability index as characteristic indicators;
[0036] Step 2: Input the feature indicators into the trained random forest algorithm model, and all decision trees in the random forest algorithm model will output a probability value of different electricity usage situations represented by the electricity usage data respectively, and then take the average of all probability values, and take the electricity usage situation with the largest probability value in the average as the current electricity usage result.
[0037] The method, in step 1, the characteristic indicators include:
[0038] Current peak-to-peak value: Total residual current peak-to-peak value Pvd i , is the difference between the previous peak value and the previous reverse peak value corresponding to sampling point i; the peak-to-peak value of the total current Pva i , is the difference between the previous peak value and the previous reverse peak value corresponding to sampling point i;
[0039] Current amplitude: The amplitude of the residual current Ad i , is the amplitude of the residual current at sampling point i; the amplitude of the total current is Aa i , is the amplitude of the total current at sampling point i;
[0040] Current integral and variance: residual current integral INTGd i , is the sum of the sampling values of the residual current at the sampling point i within a recent power frequency cycle T; the residual current variance Da i , is the variance of the residual current sampled value in the recent power frequency cycle T at the sampling point i; the total current integral INTGa i, is the sum of the total current sampling values in the recent power frequency cycle T at sampling point i; the total current variance Da i , calculate the variance of the total current sampled value at sampling point i within a recent power frequency cycle T;
[0041] Current peak value: residual current peak value Kd i , is the peak value of the current at the sampling point i for the sampling value in the recent power frequency cycle T; the total current peak value Ka i , is the peak value of the total current at sampling point i for the sampling value in a recent power frequency cycle T;
[0042] Current power information entropy: power information entropy Pse i , is the power spectrum information entropy of the current at sampling point i for the recent sampling value in a period T;
[0043] The signal proportions of different frequency bands of current: the signal proportion of the residual current low frequency band Rdl is the proportion of the signal in the low frequency section: 0-8kHz accounts for the total signal; the signal proportion of the residual current medium frequency band Rdm is the proportion of the signal in the medium frequency section: 8kHz-40kHz accounts for the total signal; the signal proportion of the residual current high frequency band Rdh is the proportion of the signal in the high frequency section: 40kHz-80kHz accounts for the total signal; the signal proportion of the total current low frequency band Ral is the proportion of the signal in the low frequency section: 0-8kHz accounts for the total signal; the signal proportion of the total current medium frequency band Rad is the proportion of the signal in the medium frequency section: 8kHz-40kHz accounts for the total signal; the signal proportion of the total current high frequency band Rah is the proportion of the signal in the high frequency section: 40kHz-80kHz accounts for the total signal;
[0044] Current waveform factor: Total residual current waveform factor Sd i , is the ratio of the RMS value of the total residual current at sampling point i in the last power frequency cycle to its absolute value; the total current waveform factor Sa i , is the ratio of the RMS value of the total current in nearly one power frequency cycle to its absolute value at sampling point i;
[0045] Current peak index: Total residual current peak index Cd i , is the ratio of the maximum residual current in the last power frequency cycle to the effective residual current in the last power frequency cycle at the i-th sampling point; the total current peak index Ca i , is the ratio of the maximum value of the total current in the past power frequency cycle to the effective value of the total current in the past power frequency cycle at the i-th sampling point;
[0046] Current pulse index: residual current pulse index Sd i, is the ratio of the maximum residual current in the past power frequency cycle to the absolute mean value of the residual current in the past one power frequency cycle at the i-th sampling moment; the total current pulse index Sa i , is the ratio of the maximum value of the total current in the past power frequency cycle to the absolute mean value of the total current in the past one power frequency cycle at the i-th sampling moment;
[0047] Fault arc zero-crossing retention probability index: calculated based on historical data sequence through long short-term memory artificial neural network.
[0048] The method and the fault arc zero-crossing retention probability index are obtained by the following steps:
[0049] The total current value change data before the current moment i is input into the trained long short-term memory artificial neural network model, and the long short-term memory artificial neural network model outputs the probability value PA of the fault arc occurring at the current moment i i ;
[0050] The total current value change data is obtained by evenly dividing the sampling points within one cycle of the current power frequency into multiple sub-data sets in chronological order, and the sub-data sets of the adjacent time before the current i moment are input as the total current value change data.
[0051] The method, the long short-term memory artificial neural network model network, is trained by the following steps:
[0052] Step 1, establishing a long short-term memory artificial neural network model;
[0053] Step 2, collect historical current data, collect data based on the power frequency cycle, and divide the data into a training set and a test set, and then divide the sampling points within a current power frequency cycle into multiple sub-data sets in chronological order;
[0054] Step 3, input the sub-dataset into the long short-term memory artificial neural network model, so as to output the probability value of the fault arc occurrence at time i, and then use the Adam algorithm to optimize the weight parameters of the model; repeat step 3 until the training objective function reaches near the preset limit, thereby completing the training;
[0055] Step 4: Input the test set into the trained model. If there is no overfitting phenomenon, the model test is completed.
[0056] In the method, in step 1, in the fully connected layer neural network of the long short-term memory artificial neural network model, the number of units, i.e., the number of hidden layer units, is 40; the learning rate is set to 0.0006; and the number of model layers is set to 3.
[0057] In the method, in step 2, the random forest algorithm model is trained by the following steps:
[0058] Step ①, establish a random forest algorithm model;
[0059] Step ②, collecting historical data including total voltage, total current and total residual current, and performing feature extraction to obtain a feature set;
[0060] Step ③, training the random forest algorithm model using the training set generated based on the feature set by the bagging method;
[0061] Step ④, then test the random forest algorithm model using the test set generated by the bagging method based on the feature set, and the training is completed after the test passes.
[0062] In the method, in the step ①, when establishing the random forest algorithm model, the model is initialized, that is, the number of decision trees in the model is solidified, and the structure of the model is solidified.
[0063] The method, in step ③, the bagging method comprises the following steps:
[0064] Step 1) Extract a sample from a historical electricity consumption dataset containing N samples and mark the number of times j;
[0065] Step 2) copy the sample and put it back into the historical electricity consumption dataset;
[0066] Step 3) Repeat steps 1) and 2) until j is equal to N, and a self-service set customfeature of the same size as the historical electricity consumption dataset is obtained. k , used for training the kth subtree.
[0067] Step 4) repeats 1), 2) and 3) until k is equal to the number of decision trees in the model, and the training set is generated; and the samples that have not been extracted from the historical electricity consumption dataset are used as the test set.
[0068] An electronic device, comprising:
[0069] one or more processors;
[0070] a storage device for storing one or more programs,
[0071] When the one or more programs are executed by the one or more processors, the one or more processors implement the described method.
[0072] A computer readable medium stores a computer program, which implements the method when executed by a processor.
[0073] The technical effect of the present invention is that the probability index of the fault arc "crossing zero and lingering" proposed by the present invention can play an early warning role in the occurrence of the fault arc. When the first "crossing zero and lingering" phenomenon is still in its infancy, the calculation model of the probability index of the fault arc "crossing zero and lingering" can keenly perceive its changing trend and output the corresponding probability to the random low-voltage customer power safety perception model as a reference. The present invention helps to improve the accuracy of the perception model, shorten the reaction time of the fault arc judgment, discover the user's safety hazards earlier, and is conducive to improving the power safety of low-voltage users.
[0074] The present invention integrates a large number of relevant features (such as peak-to-peak value, current amplitude, integral and variance, kurtosis, power information entropy, signal weights of different frequency bands, etc.), integrates fault arc, short circuit and leakage judgment, and is a comprehensive model. The input data of each decision tree in the forest model is randomly extracted from the original feature data set, without the need for feature screening, reducing the time and memory overhead caused by feature screening, and reducing the risk of negative impact of low-correlation features.
[0075] The present invention does not depend on the output result of a single model, but takes the average of the outputs of all decision trees as the final low-voltage customer perception result, which greatly reduces the probability of overfitting problems that are prone to occur in traditional neural networks, improves the efficiency of model building, and has a strong generalization ability.
[0076] The present invention uses a random forest algorithm to perceive the electricity safety of low-voltage users. Each decision tree in the random forest model outputs a probability of a fault occurring. The output values of all decision trees are averaged to obtain the average value of the entire model. This avoids the disadvantage that a single classifier of a traditional neural network is prone to falling into local extreme values during training. The integrated classifier considers multiple situations at the same time, effectively avoiding the interference of local extreme value problems.
[0077] The present invention will be further described below in conjunction with the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 A schematic diagram of a flow chart of an embodiment of the present invention;
[0079] Figure 2 A schematic diagram of the format of raw data collected by an embodiment of the present invention;
[0080] Figure 3 It is a schematic diagram of the operating mechanism of the "zero-crossing retention" judgment model in the present invention;
[0081] Figure 4 Schematic diagram of the arc occurrence probability index calculation method of the present invention;
[0082] Figure 5A schematic diagram of a sliding window selection for selecting sampling points in the calculation of arc occurrence probability index of the present invention;
[0083] Figure 6 A schematic diagram of the structure of the LSTM model for calculating the probability of arc occurrence built by the present invention;
[0084] Figure 7 This is a schematic diagram of a low-voltage user safety perception feature set of the present invention;
[0085] Figure 8 This is a schematic diagram of the bagging method principle adopted in the present invention. DETAILED DESCRIPTION
[0086] The overall architecture of this embodiment is shown in FIG. Figure 1 As shown, it includes two parts. The first part is the random forest model generation part, which mainly describes the establishment process of the random forest model; the second part is the random forest model usage part, which mainly presents how the random forest model realizes the intelligent perception of low-voltage customer electricity safety.
[0087] The following is the original data collection and feature extraction method
[0088] Simulate various power failure scenarios and normal operation status of low-voltage customers, and use the recording device to collect residual current data ID from the simulation experiment i And total current data Ia i , the sampling frequency is set to 1MHz, the power frequency is 50Hz, so each power frequency cycle includes 20,000 sampling points. The original data set matrix OriginalData is formed. The matrix structure is N rows and 5 columns, where the i-th row represents the data at the i-th sampling point, the 1st column represents the sampling point number, the 2nd column represents the residual current data, the 3rd column represents the total current data, the 4th column represents the voltage data between the live wire and the neutral wire, and the 5th column represents the label value (normal operation label: "0", short circuit label: "1", leakage label: "2", fault arc label: "3"). The original data format diagram is as follows Figure 2 shown.
[0089] Next, different features are extracted from the original data table by the following method. The features are calculated from the beginning of the second power frequency cycle of the original data (where the power frequency cycle is represented by T, and its value is 20ms):
[0090] (1) Peak-to-peak value
[0091] The peak-to-peak value of the current sampling point i is the difference between the previous peak value and the previous reverse peak value. The peak-to-peak value of the total residual current and the total current is recorded as Pvd i , Pva i .
[0092] (2) Current amplitude
[0093] The current amplitude at the current sampling point i, the amplitude of the residual current at time i is recorded as Ad i , the amplitude of the total current at time i is recorded as Aa i .
[0094] (3) Integral and variance
[0095] The integral and variance of the current sampling point i are calculated by integrating and variance-calculating the sampling values in a recent power frequency cycle T at the current sampling point i. The residual current data Id i And total current data Ia i The integral and variance of i ,Dd i INTGa i 、Da i The specific calculation formula is as follows:
[0096]
[0097]
[0098]
[0099]
[0100] Where Id mean , Ia mean It is the average value of the residual current in a recent power frequency cycle T.
[0101] (4) Kurtosis
[0102] Kurtosis is a characteristic quantity used to characterize the degree of concentration of data distribution. Specifically, it can characterize the peak degree of the probability density curve. The kurtosis of the current sampling point i is calculated by calculating the kurtosis of the sampling values in the recent period T at the current sampling point i. The residual current data Id i And total current data Ia i The kurtosis is represented by Kd i ,Ka i , and their calculation formulas are as follows:
[0103]
[0104]
[0105] The kurtosis value of the normal distribution is 3. If the calculated kurtosis value is greater than 3, it means that the data sequence is more dispersed than the normal distribution. If it is less than 3, it means that the data sequence is more concentrated than the normal distribution.
[0106] (5) Power information entropy
[0107] Information entropy, also known as Shannon entropy, is used to characterize the degree of uncertainty of random variables. The larger the information entropy, the more discrete the information sequence and the stronger the uncertainty. Conversely, the smaller the uncertainty. The power spectrum information entropy Pse is calculated by the sampling value in the recent period T at the current sampling point i. i The calculated total current power spectrum information entropy Pse i It is expressed as:
[0108]
[0109] Among them, P i Indicates the total power of the low-voltage user.
[0110] (6) Signal weights of different frequency bands
[0111] At the i-th sampling point, the residual current data Id i And total current data Ia i Perform fast Fourier transform to obtain the residual current data Id i And total current data Ia i The corresponding frequency domain form Id m and Ia m , the transformation is as follows:
[0112]
[0113]
[0114] In the frequency domain, high, medium and low frequencies are divided empirically, and the proportion of signals in different frequency bands to the total signal is calculated. The fault signal data and normal signal data can be distinguished by the proportion value. Low frequency section: 0-8kHz, medium frequency section: 8kHz-40kHz, high frequency section: 40kHz-80kHz. The expressions of the residual current low frequency signal proportion Rdl, medium frequency signal proportion Rdm, high frequency signal proportion Rdh, total current low frequency signal proportion Ral, medium frequency signal proportion Rad, and high frequency signal proportion Rah are as follows:
[0115]
[0116]
[0117]
[0118]
[0119]
[0120]
[0121] (7) Form factor
[0122] The waveform factor can reflect the difference between the waveform and the standard sine wave. It is defined as the ratio of the root mean square value of a power frequency cycle to its absolute value at the i-th sampling point. The total residual current waveform factor Sd i , and the total current waveform factor Sa i The expression is as follows:
[0123]
[0124]
[0125] (8) Peak index
[0126] The peak index is defined as the ratio of the peak value to the effective value, which can be used to characterize whether a shock event occurred in the studied time period and reflect the relative height of the peak. Specifically, at the i-th sampling point, the ratio of the maximum value of the residual current and total current in the past power frequency cycle to the effective value of the residual current and total current in the past month of the power frequency cycle is Cd. i , Ca i :
[0127]
[0128]
[0129] (9) Pulse indicator
[0130] The pulse index is defined as the ratio of the peak value to the absolute mean value of the sampling sequence, which can reflect the impact degree of the waveform. At the i-th sampling moment, the ratio of the maximum value of the residual current and total current in the past power frequency cycle to the absolute mean value of the residual current and total current in the past month's power frequency cycle Sd i , Sa i :
[0131]
[0132]
[0133] (10) Fault arc “zero-crossing retention” probability index
[0134] Traditional "zero-crossing retention" judgment methods mostly use the length of time that the current amplitude stays near zero or whether the slope of the sampling point sequence exceeds a certain fixed critical value to judge whether "zero-crossing retention" occurs. The method of calculating the residence time near zero can easily lead to a long reaction time for fault arc judgment because it can only be identified after the "zero-crossing retention" occurs; and the setting of a fixed critical value cannot adapt to various complex situations in reality, and is prone to errors such as missed judgments or misjudgments. Therefore, in response to the above problems, the present invention proposes a method that has no setting value and can predict fault arcs in the embryonic state of "zero-crossing retention". The method ultimately outputs the probability PA of arc occurrence at time i. i The schematic diagram of the model judgment mechanism is as follows: Figure 3 The left half of the figure shows that under normal circumstances, the model outputs the probability PA of "zero crossing retention" at time i according to the trend of the data sequence change in the previous period of time at time i. i , the value at this time should be low; while the right half of the figure shows that in the initial stage of the fault, at the beginning of the first "zero-crossing retention", the model can show through the sequence change trend that the rise after zero-crossing gradually decreases, and the output probability PA of the "zero-crossing retention" phenomenon at this time i , the value should be high at this time.
[0135] Therefore, the arc occurrence probability PA i It can be used as a key indicator to determine the occurrence of arc. The specific calculation method is as follows:
[0136] ① Create feature dataset
[0137] First, extract the sampling points, the columns where the total current is located, and the label columns from the original data set OriginalData to form a sub-data set OriginalDatachild, the size of which is N×3; secondly, construct the feature set corresponding to the sub-data and OriginalDatachild. Since the sampling rate is 1MHz, there are 20,000 sampling points in each cycle. Based on the experience of the proportion of "zero crossing retention" in time and the entire cycle, this method takes 1,000 points as the sliding window width, that is, construct the feature set corresponding to the sub-data set from the 1,000th sampling point of the original data. Figure 5As shown in the figure, the total current data sequence is collected in chronological order. The data sequence with time series characteristics is constructed by sliding the window and stepping one point at a time. The first 70% is divided into the training set and the last 30% is divided into the test set. The training set of the feature set is learned using the long short-term memory artificial neural network (LSTM), so that the LSTM model can judge the current state from the change trend of the recent historical current data sequence. In the early stage of the fault arc, the recent historical current data contains the trend of "zero crossing retention". The sensitive LSTM will mine important information from the historical data sequence and output the probability value PA of the fault arc at the current moment. i .
[0138] ② Training of LSTM model
[0139] Using python 3.8, in the tensorflow 2.0 framework, call the LSTM cell to create the subpackage tf.compat.v1.nn.rnn_cell.BasicLSTMCell, and set the model hyperparameters according to the empirical model as shown in Table 1:
[0140] Table 1 LSTM model hyperparameter settings
[0141]
[0142] The number of hidden layer units is the number of units in the fully connected layer neural network inside the LSTM unit, which is set to 40.
[0143] The input dimension is the number of features. 1,000 historical continuous sampling points are input at one time, and the model mines the data change rules from the sampling point sequence.
[0144] The learning rate controls how much the model adjusts parameters during training and is set to 0.0006.
[0145] The number of LSTM layers is set to 3.
[0146] Batchsize is the size of each batch of training. The present invention sets each batch of training to include 10 power frequency cycles.
[0147] The time step indicates how much historical memory is referenced each time a calculation is performed.
[0148] Weight optimization is to set the method by which LSTM optimizes the weight parameters in the model during training, and is set to the general Adam algorithm.
[0149] Input 1000 historical data and output 1 probability value, which is the probability of arc fault at time i. The LSTM model structure is as follows: Figure 6 as shown.
[0150] The Adam algorithm is used to train the constructed LSTM model based on the training set data, and the reduce_mean function in the tensorflow framework is called as the training objective function. When reduce_mean drops to near the preset limit, it means that the training is completed and the testing phase can be entered.
[0151] The preset limit value is determined by the following method:
[0152] 1) Start the model training and observe the changing trend of the output value of the objective function. The objective function expression is as follows:
[0153]
[0154] Among them, y' i Represents the i-th value in the model output vector, y i Represents the test data label value, N represents the length of the model output vector, and the meaning of loss is to take the square root of the difference between each output value and the label value in the model output vector and then take the average. The result can reflect the quality of model training under the current training level. The smaller the value, the closer it is to the target.
[0155] ② Set the limit value error to 0, keep the model in the training state, and observe the relationship between the output value of the objective function loss and the number of training times j.
[0156] ③When satisfied
[0157]
[0158] This means that the training effect of the current jth training is not much different from the training effect of the 100th training. It can be determined that the current training task has reached its limit, and the current loss can be output. j The value of is used as the preset limit value for model training.
[0159] ③Test model
[0160] The trained model is tested using the test set data to verify the generalization ability of the model. If there is no overfitting phenomenon, the model has completed the test. Overfitting here means that the model performs well on the training set but poorly on the test set, that is, the generalization performance is poor. Specifically, when the test set data is used for testing, as long as the performance of the model is not lower than that of the training set, it can be considered that there is no overfitting phenomenon.
[0161] The output value PA of the model at time i i It represents the probability of arc fault occurrence at the current moment, which can be used as a characteristic indicator and as the input of the low-voltage user safety perception model.
[0162] The following is the process of constructing the dataset used for training and testing the random forest algorithm model.
[0163] The total dimension of the features involved in the calculation is 24, the label output is 1-dimensional, and the low-voltage user power safety perception feature set is established with the sampling point as the minimum time unit. The feature set structure is as follows: Figure 7 As shown in the figure, the in-bag data of the feature set is used for training, and the out-of-bag data is used for testing. The dataset is named CustomFeature.
[0164] Then build a random forest model by following the steps below:
[0165] Using python 3.8 under the tensorflow 2.0 framework, there are several steps to build a random forest model.
[0166] (1) Import related Python packages
[0167] Import the RandomForestClassifier method from the sklearn.ensemble package, which is used to build a random forest; import the train_test_split method from the sklearn.model_selection package, which is used to divide the data set. Import the read_excel method from the pandas package to read the data.
[0168] (2) Importing the dataset
[0169] Import the previously organized CustomFeature dataset from the Excel data table. Use the read_excel method in the Pandas package to read the CustomFeature dataset and assign it to the variable: Dataset_CF.
[0170] (3) Establishing a random forest
[0171] When establishing the random forest model used in this embodiment, this embodiment sets the n_estimators value to 20, which is the number of decision trees set. This value needs to be adapted to the hardware environment of the operation. Generally speaking, the higher the value, the greater the memory overhead. In specific applications, this value can be set according to the accuracy requirements and hardware conditions.
[0172] This embodiment also sets the parameter random_state to 2 or any fixed value to ensure that the same random forest model can be generated each time the algorithm is run. In the parameter setting of the model, random_state is a random seed, which is used as a parameter in any class or function with randomness to control the random mode. When random_state takes a certain value, a rule is determined. Since the establishment of a random forest model is a random process, if the random_state parameter is not set, the model constructed each time will be random, and the experimental results cannot be fixed, but will appear randomly, that is: when the value of the random_state parameter remains unchanged, the results obtained by establishing a random forest model with the same training set are the same, and the prediction results for the test set are also the same; when its value changes, the results obtained by establishing a random forest model are different; if this parameter is not set, the function will automatically select a random mode, and the results obtained each time will be different. Adding the random_state parameter and setting it to a fixed value plays a role in controlling the random state.
[0173] This embodiment also sets the parameter bootstrap to True, that is, the bagging method is used to train the random forest, which can ensure that each decision tree model in the final forest is different. This parameter can randomly and with replacement extract a sub-dataset from the data set using the bagging method for training a single decision tree in the forest. That is, it ensures that each decision tree uses a different data set, and is similar but not the same after training. When the overall distribution of the sample is unknown and the sample cannot be accurately extracted, bootstrap can resample the sample to depict the overall distribution.
[0174] The statistical principle of Bootstrap is as follows:
[0175] Assume there is a sample x 1 ,x 2 ,...,x i , the true distribution is P, and the empirical distribution of X is: (A belongs to the overall sample space). If there is no other information, is the nonparametric maximum likelihood estimate of P.
[0176] Specifically, the steps of the bagging method are:
[0177] ① In an original data set CustomFeature containing N samples, extract a sample and mark it j times.
[0178] ② Copy the sample and put it back into the original data set to maintain the consistency of the original data set.
[0179] ③ Repeat ①② until j is equal to N, and a self-service dataset CustomFeature of the same size as the original dataset CustomFeature is obtained k , used for training the kth subtree.
[0180] ④ Repeat ①②③ until k is equal to n_estimators, that is, the number of decision trees in the model, and then stop.
[0181] Schematic diagram of the bagging method Figure 8 As shown, the self-service set is a subset of the sample set, and there may be repeated samples in the self-service set. The self-service sets are different from each other, and a decision tree is constructed to ensure that the decision trees are different from each other after training. Due to the characteristics of the random sampling method with replacement, when the sample set is large enough, there will be a part of the data that will never be drawn, as shown in formula (22). Therefore, the probability of each sample being drawn is Pslt. When n tends to positive infinity, the Pslt value will converge to 1-(1 / e), which is about 0.632, that is, there are about 37% of the data that have not participated in the training. This part of the data can be used in the test phase and is called out-of-bag data.
[0182]
[0183] Setting the parameter oob_score to True means that out-of-bag data will be used for testing.
[0184] After the parameters are set, call the fit method, use the training data as parameters, enter the training phase, and finally output the trained random forest model RF.
[0185] In order to evaluate the classification ability of the random forest model RF, the score method is called to evaluate the classification ability of the model in the test set, and the corresponding evaluation value is output as the model classification ability test indicator. When the score>0.95, it means that the classification ability of the random forest model RF is qualified and can be used for low-voltage customer power safety intelligent perception.
[0186] According to the real-time data output results, the features corresponding to the input real-time data are entered into the model RF. Each decision tree in the random forest model outputs a probability, and the total result needs to take the average of the output values of all decision trees to obtain the average value of the entire model. The predict method is used with the input of the test set as a parameter to view the output. Then the corresponding category is obtained (normal: "0", short circuit: "1", leakage: "2", arc: "3").
[0187] Furthermore, this embodiment also provides an electronic device and a computer-readable medium.
[0188] Electronic equipment includes:
[0189] one or more processors;
[0190] a storage device for storing one or more programs,
[0191] When the one or more programs are executed by the one or more processors, the one or more processors implement the aforementioned method.
[0192] In specific use, users can interact with servers, which are also electronic devices, through electronic devices as terminal devices and based on the network to achieve functions such as receiving or sending messages. Terminal devices are generally various electronic devices equipped with display devices and used based on human-computer interfaces, including but not limited to smart phones, tablet computers, laptops and desktop computers. Various specific application software can be installed on the terminal devices as needed, including but not limited to web browser software, instant messaging software, social platform software, shopping software, etc.
[0193] The server is a network service end used to provide various services, such as a backend server that provides corresponding computing services for the power consumption data transmitted from the terminal device. This enables the power consumption analysis of the received power consumption data based on the trained model, and returns the final power consumption analysis results to the terminal device.
[0194] The power safety perception method provided in this embodiment is generally executed by a server. In actual use, under the necessary conditions, the terminal device can also directly execute the power safety perception method.
[0195] Similarly, the computer-readable medium provided in this embodiment stores a computer program, which, when executed by a processor, implements the power safety perception method of this embodiment.
Claims
1. A method for electricity safety perception based on random forest algorithm, characterized in that: The following steps are involved: Step 1: Collect power consumption data and extract current peak-to-peak value, current amplitude, current integral and variance, current peak value, current power information entropy, current signal proportion of different frequency bands, current waveform factor, current peak index, current pulse index and fault arc zero crossing retention probability index as characteristic indicators; Step 2: Input the feature index into the trained random forest algorithm model, and all decision trees in the random forest algorithm model will output a probability value of different power consumption situations represented by the power consumption data, and then take the average of all probability values, and take the power consumption situation with the largest probability value in the average as the current power consumption result; In the step 1, the characteristic indicators include: Current peak-to-peak value: Total residual current peak-to-peak value Pvd i , is the difference between the previous peak value and the previous reverse peak value corresponding to sampling point i; the peak-to-peak value of the total current Pva i , is the difference between the previous peak value and the previous reverse peak value corresponding to sampling point i; Current amplitude: The amplitude of the residual current Ad i , is the amplitude of the residual current at sampling point i; the amplitude of the total current is Aa i , is the amplitude of the total current at sampling point i; Current integral and variance: residual current integral INTGd i , is the sum of the sampling values of the residual current at the sampling point i within a recent power frequency cycle T; the residual current variance Dd i , is the variance of the residual current sampled value in the recent power frequency cycle T at the sampling point i; the total current integral INTGa i , is the sum of the total current sampling values at sampling point i within a recent power frequency cycle T; the total current variance Da i , calculate the variance of the total current sampled value at sampling point i within a recent power frequency cycle T; Current peak value: residual current peak value Kd i , is the peak value of the current at the sampling point i for the sampling value in the recent power frequency cycle T; the total current peak value Ka i , is the peak value of the total current at sampling point i for the sampling value in a recent power frequency cycle T; Current power information entropy: power information entropy Pse i , is the power spectrum information entropy of the current at sampling point i for the recent sampling value in a period T; The signal proportions of different frequency bands of current: the signal proportion of the residual current low frequency band Rdl is the proportion of the signal in the low frequency section: 0-8kHz accounts for the total signal; the signal proportion of the residual current medium frequency band Rdm is the proportion of the signal in the medium frequency section: 8kHz-40kHz accounts for the total signal; the signal proportion of the residual current high frequency band Rdh is the proportion of the signal in the high frequency section: 40kHz-80kHz accounts for the total signal; the signal proportion of the total current low frequency band Ral is the proportion of the signal in the low frequency section: 0-8kHz accounts for the total signal; the signal proportion of the total current medium frequency band Rad is the proportion of the signal in the medium frequency section: 8kHz-40kHz accounts for the total signal; the signal proportion of the total current high frequency band Rah is the proportion of the signal in the high frequency section: 40kHz-80kHz accounts for the total signal; Current waveform factor: Total residual current waveform factor Sd i , is the ratio of the RMS value of the total residual current at sampling point i in the last power frequency cycle to its absolute value; the total current waveform factor Sa i , is the ratio of the RMS value of the total current in nearly one power frequency cycle to its absolute value at sampling point i; Current peak index: Total residual current peak index Cd i , is the ratio of the maximum residual current in the last power frequency cycle to the effective residual current in the last power frequency cycle at the i-th sampling point; the total current peak index Ca i , is the ratio of the maximum value of the total current in the past power frequency cycle to the effective value of the total current in the past power frequency cycle at the i-th sampling point; Current pulse index: residual current pulse index Sd i , is the ratio of the maximum residual current in the past power frequency cycle to the absolute mean value of the residual current in the past one power frequency cycle at the i-th sampling moment; the total current pulse index Sa i , is the ratio of the maximum value of the total current in the past power frequency cycle to the absolute mean value of the total current in the past one power frequency cycle at the i-th sampling moment; Fault arc zero-crossing retention probability index: calculated based on historical data sequence through long short-term memory artificial neural network; The fault arc zero-crossing retention probability index is obtained by the following steps: The total current value change data before the current moment i is input into the trained long short-term memory artificial neural network model, and the long short-term memory artificial neural network model outputs the probability value PA of the fault arc occurring at the current moment i i ; The total current value change data is obtained by evenly dividing the sampling points within one cycle of the current power frequency into multiple sub-data sets in chronological order, and the sub-data sets of the adjacent time before the current i moment are input as the total current value change data.
2. The method according to claim 1, characterized in that The long short-term memory artificial neural network model is trained by the following steps: Step 1, establishing a long short-term memory artificial neural network model; Step 2, collect historical current data, collect data based on the power frequency cycle, and divide the data into a training set and a test set, and then divide the sampling points within a current power frequency cycle into multiple sub-data sets in chronological order; Step 3, input the sub-dataset into the long short-term memory artificial neural network model, so as to output the probability value of the fault arc occurrence at time i, and then use the Adam algorithm to optimize the weight parameters of the model; Repeat step 3 until the training objective function reaches the preset limit, thus completing the training; Step 4: Input the test set into the trained model. If there is no overfitting phenomenon, the model test is completed.
3. The method according to claim 2, characterized in that In the step 1, in the fully connected layer neural network of the long short-term memory artificial neural network model, the number of units, i.e., the number of hidden layer units, is 40; the learning rate is set to 0.0006; and the number of model layers is set to 3.
4. The method according to claim 1, characterized in that: In the step 2, the random forest algorithm model is trained by the following steps: Step ①, establish a random forest algorithm model; Step ②, collecting historical data including total voltage, total current and total residual current, and performing feature extraction to obtain a feature set; Step ③, training the random forest algorithm model using the training set generated based on the feature set by the bagging method; Step ④, then test the random forest algorithm model using the test set generated by the bagging method based on the feature set, and the training is completed after the test passes.
5. The method according to claim 4, characterized in that In the step ①, when establishing the random forest algorithm model, the model is initialized, that is, the number of decision trees in the model is solidified, and the structure of the model is solidified.
6. The method according to claim 4, characterized in that In the step ③, the bagging method comprises the following steps: Step 1) Extract a sample from a historical electricity consumption dataset containing N samples and mark the number of times j; Step 2) copy the sample and put it back into the historical electricity consumption dataset; Step 3) Repeat steps 1) and 2) until j is equal to N, and a self-service set customfeature of the same size as the historical electricity consumption dataset is obtained. k , used for training the kth subtree; Step 4) repeats 1), 2) and 3) until k is equal to the number of decision trees in the model, and the training set is generated; and the samples that have not been extracted from the historical electricity consumption dataset are used as the test set.
7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
