An algorithm for detecting abnormal electricity mode of power users

In order to reduce the non-technical loss and reduce the operating cost of the power company, an abnormal power consumption detection algorithm is proposed. The algorithm includes feature extraction, principal component analysis, grid processing, local outliers, and so on. Firstly, we extract several feature quantities that characterize the user's power consumption pattern, and map the X users to the two-dimensional plane by principal component analysis. Data visualization and easy to calculate local outliers, and grid processing techniques to filter out data points in low density regions. The algorithm is used to reduce the number of training samples in the power user data set, and to output the anomalies and probabilities of all users' behavior. The experimental results show that the use of the sorting only need to detect the anomaly of a few users can find a large number of abnormal users, significantly improve the efficiency of the algorithm.


Introduction
With the popularity of information technology, large data age has come, a close concern of all walks of life is a hot issue, how to extract a lot of data from the meaningful information.For the power industry, with the rapid growth of the amount of electricity with the power system and the continuous improvement of the degree of information system, all kinds of systems and devices have a lot to deal with the data, large-scale data, a wide range of event information."Massive data, information is scarce" is still the main problem facing [1].
The purpose of this paper is to sort the abnormalities and probabilities of users' electricity behavior.Effective anomaly detection can provide reference for decision-making of power supply company, improve the efficiency of on-site inspection, reduce operating costs, save a lot of manpower and material resources, can improve economic efficiency [2][3][4].

Outlier object mining 2.1 Local outlier factor algorithm
Outlier object mining is defined as: Given a set of k objects, assuming that the expected number of outliers is n, finding the first n objects with the most significant difference compared to the rest.
The local outlier factor algorithm has the following definitions [5]: Definition 1 The n-distance neighborhood of object x The n-distance neighborhood of object x is the set of objects that are no more than n-distance from x Nn(x)={yD\{x}|d(x,y)  n_dist(x)} (1) Definition 2 Up to the distance Let n be a natural number, then the reachable distance of object x with respect to object y is defined as reach_distn (x,y)=max {k_dist(y), d(x,y)} (2) Definition 3 Local reachable density Let m be a positive integer, then the local reachable density of object x is

Definition 4 Local outliers
The local outliers of object x are defined as The lower the local reach density of the object x, the greater the local reach density of the m nearest neighbor objects, and the larger the local outlier factor LOF of the object x.If x is an object of large degree of outliers, then l is smaller and the neighborhood of the object in the neighborhood is larger, that is, the local outlier factor LOF of object x is relatively large; if x is the object in the cluster, The difference between the I and the I values in the neighborhood is small, that is, the local outliers of the object x are close to l.The use of this feature can eliminate the impact of different clusters of density differences.It can be considered that objects with higher LOF values are outliers.

Local outlier factor based on grid algorithm
The grid-based local outlier factor algorithm is divided into the following steps: 1) import the database, the establishment of data space model.
2) Determine the division interval and interval length for each dimension.
3) Get the label of the grid where each data object is located, and the grid count is incremented by one.Scans all objects in the dataset to get the number of objects that each grid contains.
4) Detect each grid adjacent grid, marking whether the current grid is an internal grid.5) remove all objects in the internal grid, calculate the remaining objects of the local outliers.

Load sequence feature extraction
The data set contains N months of electricity users W months of electricity data, electricity mode with the monthly average load to represent each user's load sequence is expressed as The feature quantity of the user power mode can be extracted on the basis of the data set D.

Trends indicators
The trend indicators are calculated as follows: 1) Enter the data set D of the monthly average load of the power user; 2) Calculate the n-point simple moving average sequence A of each user load time series T; 3) Calculate the rising trend indicators Up and down trend indicators Down.

Variability indicators
The variability indicator refers to the difference between the head and the end of the electricity user's power consumption model, including: 1) the difference between the average c month and the c month average load is 2) The coefficients of the difference sequence of the coefficient series of the previous c months and the c-month discrete Fourier transform are where yk1 and yk2 are the coefficients of c months before and after the discrete Fourier transform, respectively.
3) the slope of each user W month load data linear fit.

Volatility indicators
1) the standard deviation sd of the W month load sequence for each user.
2) the standard deviation of the previous c month load sequence bed_c.
3) after the c month load sequence standard deviation red_c.

Principal component analysis
Principal component analysis is a data dimensionality reduction method.The basic idea is to re-combine the original indicators Z1, Z2, ... Ze into a number of less comprehensive and irrelevant comprehensive indicators.The integrated indicator should reflect the information represented by the original variable to the greatest extent and ensure that the new indicators remain independent of each other [6].If G1, G2, ..., Gf are used to represent the f principal components of the original variables Z1, Z2, ... Ze, which is

Model evaluation method
Exceptional power mode detection is essentially a binary classification problem, that is, all users are divided into two categories: normal users and abnormal users.The confounding matrix is a basic tool for assessing the confidence of the classifier [7].For the binary classification problem, the confounding matrix shown in table 1 shows all possible classification results for the classifier, where the positive (negative) corresponds to the object's actual The category, column (true / false) that belongs to the category predicted by the classifier.where FP is the first type of error, FN is the second type of error.On the basis of the confusion matrix, the evaluation indexes of multiple classifiers can be deduced: precision = TP / (TP + FP), recall rate RecaII = TP / (TP + FN), TPR = TP / FN), FPR = FP / (TP + FN) and so on.

Case study
This paper uses the data set for a provincial power grid 6200 power users 18 months of electricity load data, sampling interval of 30 minutes.Electricity load and electricity consumption can be two kinds of indicators can be converted into each other, the two reflect the rules of the user electricity is essentially the same, you can also use electricity as a description of the user power model characteristics.First, the raw data set is processed, the monthly average load of each user is calculated, and the monthly average load time series of each user is constructed.Then, on the basis of the time series, a number of trend indicators and variability indicators are proposed to reflect their electricity consumption patterns.The load curve (load sequence) hereinafter refers to the time series consisting of the average load per month.6200 power users, including 6123 normal users and 77 abnormal users, the proportion of abnormal users 1.24%.The input of the model is the original data set, and the output is sorted by user anomaly and probability.

Feature extraction and dimension reduction
The local outliers LOF of all points on the two-dimensional plane are calculated and the LOF is used as a quantization index of the anomaly of the electricity pattern.Fig. 1 is to evaluate the ROC curve of the prediction model, and the area under the curve can be calculated on the basis of the ROC curve.In fig. 1, the AUC of PCA corresponds to 0.827, and the corresponding AUC of FA is 0.777.It can be seen that the use of principal component analysis to map the power users to the two-dimensional plane is better than the factor analysis.So the following principal component analysis is used to model.

Grid processing technology
From the cumulative recall rate curve in fig.2, the curve can be roughly divided into two stages.The detection rate is less than 0.2, and the detection rate is more than 0.2.The importance of these two phases is different for the purpose of mining unusual users.The previous stage of the curve shows that only about 20% of the users can detect about 70% of the abnormal users, the latter stage shows that the remaining 80% of users can only detect 30% of the abnormal users, that CR curve front Part of the study is the focus of attention.Based on the above analysis, we can see that the GridLOF algorithm can guarantee the efficiency of the algorithm with the same accuracy rate as the LOF algorithm.

Model parameter analysis
Unsupervised Exceptional Power Mode There are two important parameters in the model: the number of lattice divisions w and the neighborhood k of the local outliers.
It can be seen from table 3 that the calculation time increases rapidly with the increase of w, because the grid is finer when the value of w is larger, the more data points are retained, the longer the calculation time is, and the AUC is the same as w Variety.

Conclusion
The detection model of abnormal power consumption based on unsupervised learning includes feature extraction, principal component analysis, grid processing, local outlier factor calculation and so on.1) Principal component analysis can reduce the dimensionality of electricity feature set and eliminate the overlap of information between original features.Using the first two principal components to represent the power consumption pattern of each power user, the normal user can be mapped to the high density area on the two-dimensional plane, the abnormal user is mapped to the low density area, and the mapping effect of the principal component analysis is better than the factor analysis.
2) Introducing the grid technique into the LOF algorithm to filter the data points of the low density region through the boundary grid, which has little effect on the accuracy of the model, but can significantly improve the computational efficiency.The interval interval w and the nearest neighbor k are the model of the two important parameters.The results show that the sensitivity of the parameters w and k is low, that is, the model has high stability.
3) The cumulative recall rate curve of the model rises rapidly when the detection rate is small, and tends to be gentle when the detection rate is large.Note that the use of the output of the model, only need to detect the anomaly of the front row of a small number of users can find most of the abnormal users.
Follow-up, we will study the non-barbed learning and prison learning together to further capture the abnormal power consumption of the detection accuracy and detection efficiency.

Fig. 2 .
Fig.2.Cumulative recall curve for LOF.It can be seen from table 2 that the AUC values of the GridLOF and LOF algorithms are very different when the parameters k are different.Change the size of the data set, compare LOF and GridLOF calculation time, as shown in fig.2.

Table 2 .
AUC of the two algorithms for different k values.

Table 3 .
Computing time and AUC of GridLOF for different subdivision.