Electricity stealing detection method based on k neighborhood rough set
Through the k-nearest neighbor rough set theory, the k-nearest neighbor relationship matrix and particle set are constructed, and the anomalies are calculated, which solves the problems of uncertain data processing and information loss in power plagiarism detection, and realizes unsupervised abnormal detection of power consumption data. Improves detection efficiency and accuracy.
Patent Information
- Application Number
- CN202410922562.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-10
- Publication Date
- 2024-11-15
AI Technical Summary
The prior art is difficult to process uncertain data in power theft detection, easily lose information, and requires a large amount of manual labeling of data, which limits the performance improvement of the abnormal detection algorithm for power consumption data.
Using the power stolen detection method based on the k-nearest neighbor rough set, by obtaining electricity consumption data, performing standardized processing, calculating k-distance, constructing k-nearest neighbor relationship matrix and particle set, calculating approximate accuracy and local reachable density, and evaluating particle anomaly , realize unsupervised abnormal detection and avoid information loss caused by data format conversion.
Effectively process uncertain data, avoid information loss, realize multi-angle reorganization and abnormal detection of electricity consumption data, improve the accuracy and efficiency of power theft detection without labeling data for model training.
Smart Images

Figure CN118965213A_ABST
Abstract
Description
[0001] Technology Neighborhood
[0002] The invention belongs to the technical field of electricity consumption data analysis, and in particular relates to an electricity theft detection method based on k-nearest neighborhood rough sets. Background Art
[0003] At present, in the smart grid neighborhood, electricity theft may disrupt the normal order of electricity consumption, thereby causing serious loss of economic benefits to power supply companies. In addition, electricity theft may also bring safety hazards to users and electricity thieves themselves. Therefore, electricity theft detection has important research significance and practical application value in ensuring the safety of power supply, promoting the reliable operation of the power grid and maintaining the economic interests of power companies. At present, machine learning-based methods have been widely used in power big data analysis and mining. However, in electricity theft detection, most of these methods are not good at processing deterministic data and are prone to losing important information; they require a large amount of manually labeled data, which limits the improvement of the performance of electricity data anomaly detection algorithms. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the present invention provides a method for detecting electricity theft based on k-nearest neighbor rough sets, which solves the problem that the existing electricity consumption data anomaly detection is difficult to handle uncertain data, and can avoid information loss caused by data format conversion, and effectively realize unsupervised anomaly detection of hybrid power data.
[0005] In order to achieve the above objectives, the technical solution adopted by the present invention is: a method for detecting electricity theft based on k-nearest-neighborhood rough sets, comprising the following steps:
[0006] S1. Obtaining electricity consumption data, and performing standardized processing on the electricity consumption data to obtain standardized electricity consumption data;
[0007] S2. According to the normalized electricity consumption data, select an attribute subset and calculate the kth distance of each sample with respect to the attribute subset;
[0008] S3, according to the k-th distance and k-nearest neighborhood rough set theory, calculate the k-nearest neighborhood relationship matrix and the reachable distance of each sample with respect to the selected attribute subset;
[0009] S4, constructing a k-neighborhood particle set according to the k-nearest neighbor relationship matrix and calculating the approximate accuracy of each particle;
[0010] S5. Calculate the local reachability density of each sample according to the reachable distance;
[0011] S6. Calculate the particle size anomaly of each particle based on the approximate accuracy and the local reachable density;
[0012] S7, according to the particle anomaly degree, the particle anomaly degree of all samples in the normalized electricity consumption data with respect to the k nearest neighbor particles of the selected different attribute subsets is integrated as the anomaly score of each sample;
[0013] S8. Determine whether the abnormal score of each sample is greater than a preset threshold value one by one. If yes, output the abnormal point of the electricity consumption data. Otherwise, regard it as a normal point and judge the next sample. Repeat step S8 until all samples are judged.
[0014] The beneficial effects of the present invention are as follows: the present invention avoids the problem of information loss caused by data format conversion by constructing a k-nearest neighbor relationship matrix; at the same time, k-nearest neighbor particles are constructed through different attribute subsets to obtain a multi-angle k-nearest neighbor particle set, thereby realizing the reorganization of electricity consumption data information; the uncertainty, sample density and abnormal characteristics of information particles are respectively characterized through the approximate accuracy, local reachable density and particle abnormality of the k-nearest neighbor particles, and then the abnormality of the samples is calculated by integrating the abnormal factors of the k-nearest neighbor particles; the present invention does not need to mark electricity consumption data for model training, and can effectively realize electricity theft detection of electricity consumption data.
[0015] Furthermore, the expression of the standard processing is as follows:
[0016]
[0017] Among them, F(f(x,a)) represents the normalization function, f(x,a) represents the value of sample x in the electricity consumption data on attribute a, x represents the sample in the electricity consumption data, max a and min a They represent the maximum and minimum values of sample x with respect to attribute a respectively.
[0018] The beneficial effect of the above further solution is that the present invention reduces the amount of data calculation by normalizing the numerical data in the electricity consumption data.
[0019] Furthermore, step S2 includes the following steps:
[0020] S201, selecting attribute subsets based on the normalized electricity consumption data, denoted as B and P;
[0021] S202, calculate the kth distance of each sample with respect to the attribute subset, where sample x i The k-th distance about attribute subset B is denoted as k-dist B (x i ), which satisfies:
[0022] There are at least k samples x in the sample set U j ∈U satisfies d B (xi ,x j )≤d B (x i ,x' j );
[0023] There are at most k-1 samples x in the sample set U j ∈U satisfies
[0024] Among them, d B (x i ,x j ) represents the sample x i With sample x j The distance function of attribute subset B, x i 、x j and x' j All represent samples;
[0025] Sample x i The k-th distance about the attribute subset P is denoted as k-dist P (x i ), which satisfies:
[0026] There are at least k samples x in the sample set U j ∈U satisfies d P (x i ,x j )≤d P (x i ,x' j );
[0027] There are at most k-1 samples x in the sample set U j ∈U satisfies Among them, d P (x i ,x j ) represents the sample x i With sample x j The distance function of about the attribute subset P.
[0028] The beneficial effect of the above further scheme is: using the kth distance of the sample as the neighborhood radius to achieve data granulation, different attribute subsets can obtain different granulation results, and data information can be more fully utilized.
[0029] Furthermore, step S3 includes the following steps:
[0030] S301, according to k-dist B (x), k-dist P (x) and k-nearest-neighbor rough set theory, calculate the k-nearest-neighbor relationship matrix of the sample set U with respect to the attribute subset B and the attribute subset P;
[0031] S302, according to k-dist B (x i ) and k-dist P (x i ), calculate the reachable distance of each sample with respect to attribute subset B and attribute subset P.
[0032] The beneficial effect of the above further scheme is that for all samples close to x j Sample x i , d B (x i ,x j ) can be significantly reduced. If the sample x i Outlier sample x j Very far away, is their actual distance with respect to attribute subset B. If sample x i Outlier sample x j is close enough, then the sample x i With sample x j About the reachable distance of attribute subset B Equal to the distance function k-dist B (x).
[0033] Furthermore, the expressions of the k-nearest neighbor relationship matrices of the sample set U with respect to the attribute subset B and the attribute subset P are as follows:
[0034]
[0035] in, and They represent the k-nearest neighbor relationship matrices of the sample set U with respect to the attribute subset B and the attribute subset P, respectively. Represents the k-nearest neighbor relationship matrix The i-th row and j-th column element of Represents the k-nearest neighbor relationship matrix The i-th row and j-th column element of , n represents the total number of samples;
[0036] The expressions of the reachable distances of the samples with respect to the attribute subset B and the attribute subset P are as follows:
[0037]
[0038] in, Represents sample x i With sample x j Regarding the reachable distance of attribute subset B, Represents sample x i With sample x jThe reachability distance for a subset of attributes P.
[0039] Furthermore, step S4 includes the following steps:
[0040] S401, constructing a k-neighborhood particle set according to a k-nearest-neighborhood relationship matrix;
[0041] S402. Calculate the approximate accuracy of each particle based on the constructed k-neighborhood particle set.
[0042] The beneficial effect of the above further scheme is: different k-nearest neighbor particles are constructed from different attribute subsets, so that the description of the characteristics of electricity consumption data is more accurate. The approximate accuracy of the k-nearest neighbor particle can reflect the uncertainty of the particle about the given knowledge. The smaller the approximate accuracy of the k-nearest neighbor particle, the higher the uncertainty of the particle; the greater the approximate accuracy of the k-nearest neighbor particle, the lower the uncertainty of the particle.
[0043] Furthermore, the expression of the k-neighborhood particle set is as follows:
[0044]
[0045]
[0046] in, and They represent the k-nearest neighbor particle sets derived from attribute subset B and attribute subset P, respectively. and They represent the k-nearest neighbor relationship of the sample set U with respect to the attribute subset B and the attribute subset P, respectively. and Indicates that the sample x i Centered on k-dist B (x i ) and k-dist P (x i ) is the k-nearest neighbor particle of radius, i=1,2,...,n, n is the total number of samples, i is the sample number, U is the sample set, B and P are attribute subsets;
[0047] The expression of the approximate accuracy of each particle is as follows:
[0048]
[0049] in, It means that the sample x i Centered, k-dist B (x i ) is the radius of the k nearest neighbor particles, Indicates that the sample x j Centered, k-distP (x j ) is the radius of the k nearest neighbor particles, express Regarding the approximate accuracy of the attribute subset P, express The lower approximation of the attribute subset P is: express About the upper approximation of attribute subset P, |*| represents the scale operation, x i and x j All represent samples, represents the set of k nearest neighbor particles derived from the attribute subset P, i and j represent the sample labels, and U represents the sample set.
[0050] Furthermore, the expression of the local reachable density is as follows:
[0051]
[0052] Among them, lden B (x i ) represents the local reachability density with respect to attribute subset B, Represents sample x i With sample x j Regarding the reachable distance of attribute subset B, represents the k-nearest neighbor relationship of the sample set U with respect to the attribute subset B, |*| represents the scale operation, It represents the k-nearest neighbor relationship matrix of sample set U with respect to attribute subset B, i and j represent sample numbers, and n represents the total number of samples.
[0053] The beneficial effect of the above further scheme is that the local reachable density is a description of the sample density in the information particle, by integrating the reachable distance and the particle size. The abnormal characteristics of the k-nearest neighbor particles are characterized by the local reachable density, which is used as a screening factor for abnormal points to improve the accuracy of abnormal point screening.
[0054] Furthermore, the expression of the particle size abnormality is as follows:
[0055]
[0056] in, express The particle size abnormality, lden B (x) represents the local reachability density with respect to attribute subset B, represents k nearest neighbor particles The accuracy of the approximation with respect to a subset P of attributes.
[0057] The beneficial effect of the above further scheme is: the abnormal characteristics of the k nearest neighboring particles are characterized by the particle abnormality, which is used as a screening factor for abnormal points, thereby improving the accuracy of abnormal point screening.
[0058] Furthermore, the expression of the anomaly score is as follows:
[0059]
[0060] Where kNNAS(x) is the anomaly score, kNNAS(·) is the calculation function of the anomaly score, represents the particle anomaly degree, GAD(·) represents the particle anomaly degree calculation function, m represents the total number of attributes, and h represents the attribute label.
[0061] The beneficial effect of the above further solution is that the abnormality score of the object is calculated by averaging the particle abnormality of particles in different k nearest neighbor domains, so that the abnormality degree of the object can be evaluated more comprehensively. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] Figure 1 The present invention is a flow chart of the method. DETAILED DESCRIPTION
[0063] The specific implementation modes of the present invention are described below to facilitate the understanding of the present invention by those skilled in the art. However, it should be clear that the present invention is not limited to the scope of the specific implementation modes. For those of ordinary skill in the art, as long as various changes are within the spirit and scope of the present invention as defined and determined by the attached claims, these changes are obvious, and all inventions and creations utilizing the concept of the present invention are protected.
[0064] Example
[0065] In this embodiment, the k-nearest neighbor rough set theory provides an effective tool to overcome the discretization problem, and can be directly applied to the analysis model of numerical and categorical attributes, thereby avoiding the information loss problem caused by data format conversion. In the specific application of the k-nearest neighbor rough set, the electricity consumption data is imported into an information system (or information table), in which each row represents an object (or sample), and each column represents an attribute (feature) of the object. The value of the attribute can include numerical type (such as power consumption, voltage, etc.), categorical type (such as user type, wiring method), mixed type (including both numerical type and categorical type), etc. An information system is represented as (U, A), where U represents the set of all objects and A represents the set of all attributes.
[0066] In this embodiment, firstly, by constructing a k-nearest neighbor relationship matrix, the problem of information loss caused by data format conversion is avoided; at the same time, k-nearest neighbor particles are constructed through different attribute subsets to obtain a multi-angle k-nearest neighbor particle set to achieve reorganization of data information; the uncertainty, sample density and abnormal characteristics of information particles are characterized respectively through the approximate accuracy, local reachable density and particle abnormality of the k-nearest neighbor particles, and then the abnormality of the sample is calculated by integrating the abnormal factors of the k-nearest neighbor particles; this method does not require labeled data for model training and can effectively realize electricity theft detection of electricity consumption data.
[0067] In this embodiment, in the k-nearest neighbor rough set theory, a k-nearest neighbor particle (or "information particle" or "particle") is a set of objects aggregated by the k-nearest neighbor relationship matrix between objects. Data features are extracted by constructing k-nearest neighbor particles from multiple angles, and then the uncertainty of information particles is measured by approximate accuracy, such as Figure 1 As shown, the present invention provides a method for detecting electricity theft based on k-nearest neighbor rough sets, and its implementation method is as follows:
[0068] S1. Obtaining electricity consumption data, and performing standardized processing on the electricity consumption data to obtain standardized electricity consumption data;
[0069] The expressions processed by the specification are as follows:
[0070]
[0071] Among them, F(f(x,a)) represents the normalization function, f(x,a) represents the value of sample x in the electricity consumption data on attribute a, x represents the sample in the electricity consumption data, max a and min a They represent the maximum and minimum values of sample x with respect to attribute a respectively.
[0072] In this embodiment, the value range of the data is adjusted to a real number interval from 0 to 1 through a min-max normalization operation.
[0073] S2. According to the normalized electricity consumption data, select the attribute subset and calculate the kth distance of each sample with respect to the attribute subset. The implementation method is as follows:
[0074] S201, selecting attribute subsets based on the normalized electricity consumption data, denoted as B and P;
[0075] S202, calculate the kth distance of each sample with respect to the attribute subset, where sample x i The k-th distance about attribute subset B is denoted as k-dist B (x i ), which satisfies:
[0076] There are at least k samples x in the sample set U j ∈U satisfies d B (x i ,x j )≤d B (x i ,x' j );
[0077] There are at most k-1 samples x in the sample set U j ∈U satisfies
[0078] Among them, d B (x i ,x j ) represents the sample x i With sample x j The distance function of attribute subset B, x i 、x j and x' j All represent samples;
[0079] Sample x i The k-th distance about the attribute subset P is denoted as k-dist P (x i ), which satisfies:
[0080] There are at least k samples x in the sample set U j ∈U satisfies d P (x i ,x j )≤d P (x i ,x' j );
[0081] There are at most k-1 samples x in the sample set U j ∈U satisfies
[0082] Among them, d P (x i ,x j ) represents the sample x i With sample x j The distance function of about the attribute subset P.
[0083] In this embodiment, the kth distance is the granulation criterion in the k-nearest neighborhood rough set theory. i ∈U,x i The kth distance represents the object x i The distance to the farthest object among its k nearest neighbors.
[0084] In this embodiment, any attribute subset can construct a set of k-nearest neighbor relationship matrices, and multiple k-nearest neighbor relationship matrices can more comprehensively reflect the relationship between objects. To simplify the calculation, only a single attribute is used to construct an information particle (i.e., a basic k-nearest neighbor particle). From all attributes A = {a1, a2, ..., a m} select one attribute a at a time h , forming an attribute subset B h ={a h}, attribute subset B h The complement P h =A-{a h}, where a m Represents the mth attribute.
[0085] S3. According to the k-th distance and k-nearest neighborhood rough set theory, the k-nearest neighborhood relationship matrix and the reachable distance of each sample with respect to the selected attribute subset are calculated. The implementation method is as follows:
[0086] S301, according to k-dist B (x), k-dist P (x) and k-nearest-neighbor rough set theory, calculate the k-nearest-neighbor relationship matrix of the sample set U with respect to the attribute subset B and the attribute subset P;
[0087] S302, according to k-dist B (x i ) and k-dist P (x i ), calculate the reachable distance of each sample with respect to attribute subset B and attribute subset P.
[0088] In this embodiment, the k-nearest-neighbor relationship matrix is the core concept of the k-nearest-neighbor rough set theory, and refers to a k-nearest-neighbor relationship expression defined on U×U. i ,x j )∈U×U, sample x i With sample x j The relationship between attribute subset B can be expressed as a k-nearest neighbor relationship matrix Any attribute subset B and P can induce the k-nearest neighbor relationship matrix and The calculation formula is:
[0089]
[0090] in, and They represent the k-nearest neighbor relationship matrices of the sample set U with respect to the attribute subset B and the attribute subset P, respectively. Represents the k-nearest neighbor relationship matrix The i-th row and j-th column element of Represents the k-nearest neighbor relationship matrix The i-th row and j-th column element of , n represents the total number of samples.
[0091] In this embodiment, the reachable distance can effectively reduce the statistical fluctuation of the distance between objects, and the expression is:
[0092] The expressions of the reachable distances of each sample with respect to attribute subset B and attribute subset P are as follows:
[0093]
[0094] in, Represents sample x i With sample x j Regarding the reachable distance of attribute subset B, Represents sample x i With sample x j The reachability distance for a subset of attributes P.
[0095] S4. According to the k-nearest neighbor relationship matrix, a k-neighbor particle set is constructed and the approximate accuracy of each particle is calculated. The implementation method is as follows:
[0096] S401, constructing a k-neighborhood particle set according to a k-nearest-neighborhood relationship matrix;
[0097] S402. Calculate the approximate accuracy of each particle based on the constructed k-neighborhood particle set:
[0098]
[0099] in, It means that the sample x i Centered, k-dist B (x i ) is the radius of the k nearest neighbor particles, Indicates that the sample x j Centered, k-dist P (x j ) is the radius of the k nearest neighbor particles, express Regarding the approximate accuracy of the attribute subset P, express The lower approximation of the attribute subset P is: express The upper approximation of the attribute subset P, |*| represents the scale operation, x i and x j All represent samples, represents the set of k nearest neighbor particles derived from the attribute subset P, i and j represent the sample labels, and U represents the sample set.
[0100] In this embodiment, the process of constructing information granules is also called information granulation. Information granulation is the process of dividing all objects into particles of different granularity (i.e., granularity). In the k-nearest neighbor rough set theory, a group of objects can be aggregated to form information granules through the k-nearest neighbor relationship matrix between objects. Using any k-nearest neighbor relationship matrix Divide all objects U into a set of k nearest neighbor particle sets, namely, k nearest neighbor particle sets:
[0101]
[0102] in, and They represent the k-nearest neighbor particle sets derived from attribute subset B and attribute subset P, respectively. and They represent the k-nearest neighbor relationship of the sample set U with respect to the attribute subset B and the attribute subset P, respectively. and Indicates that the sample x i Centered on k-dist B (x i ) and k-dist P (x i ) is the k-nearest neighbor particle with a radius, i = 1, 2, ..., n, n is the total number of samples, i is the sample number, U is the sample set, and B and P are attribute subsets.
[0103] Obviously, information particles is a sample set on the sample set U, which consists of:
[0104]
[0105] Information Grains The scale is:
[0106]
[0107] In this embodiment, different k-nearest neighbor particles are constructed by different attribute subsets, so that the description of data features is more accurate. The approximate accuracy of the k-nearest neighbor particle can reflect the uncertainty of the particle about the given knowledge. The smaller the approximate accuracy of the k-nearest neighbor particle, the higher the uncertainty of the particle; the greater the approximate accuracy of the k-nearest neighbor particle, the lower the uncertainty of the particle. The uncertainty of the k-nearest neighbor particle is characterized by the approximate accuracy as a screening factor for the k-nearest neighbor particle abnormality factor, thereby improving the accuracy of abnormal point screening.
[0108] S5. Calculate the local reachability density of each sample based on the reachable distance:
[0109]
[0110] Among them, lden B (x i ) represents the local reachability density with respect to attribute subset B, Represents sample x i With sample x j Regarding the reachable distance of attribute subset B, represents the k-nearest neighbor relationship of the sample set U with respect to the attribute subset B, |*| represents the scale operation, It represents the k-nearest neighbor relationship matrix of sample set U with respect to attribute subset B, i and j represent sample numbers, and n represents the total number of samples.
[0111] In this embodiment, the local reachable density is a description of the sample density in the information particle, which is achieved by integrating the reachable distance and the particle size. The abnormal characteristics of the k-nearest neighbor particles are characterized by the local reachable density, which is used as a screening factor for abnormal points to improve the accuracy of abnormal point screening.
[0112] S6. Calculate the particle size anomaly of each particle based on the approximate accuracy and local reachable density:
[0113]
[0114] in, express The particle size abnormality, lden B (x) represents the local reachability density with respect to attribute subset B, represents k nearest neighbor particles The accuracy of the approximation with respect to a subset P of attributes.
[0115] In this embodiment, the abnormal characteristics of the k nearest neighboring particles are characterized by the particle abnormality, which is used as a screening factor for abnormal points to improve the accuracy of abnormal point screening.
[0116] S7. According to the particle anomaly degree, the particle anomaly degree of all samples in the electricity consumption data after normalization processing with respect to the k nearest neighbor particles of the selected different attribute subsets is integrated as the anomaly score of each sample:
[0117]
[0118] Among them, kNNAS(*) represents the calculation function of the anomaly score, GAD(*) represents the calculation function of the granular anomaly degree, Represents the sample set U with respect to the attribute subset B h k nearest neighbor relationship, A is the set of all attributes, |*| represents the size of *, m represents the total number of attributes, B h is a subset of attributes, and h represents the attribute number.
[0119] S8. Determine whether the abnormal score of each sample is greater than a preset threshold value one by one. If yes, output the abnormal point of the electricity consumption data. Otherwise, regard it as a normal point and judge the next sample. Repeat step S8 until all samples are judged.
[0120] In this embodiment, an information table containing 6 samples and 3 attributes is given, as shown on the left side of Table 1 (the right side is the result after normalization), and Table 1 is a table of original data and normalized results.
[0121] Table 1
[0122]
[0123] Step 1: Data normalization.
[0124] To facilitate subsequent calculations, the input data is first subjected to min-max normalization operations to convert the numerical data into values between 0 and 1. The processing results are shown on the right side of Table 1.
[0125] Step 2: Select a subset of attributes and calculate the kth distance.
[0126] Take attribute subset B h ={a h}, attribute subset B h The complement P h =A-{a h}, parameter k = 2, and the k-th distance of each sample with respect to the attribute subset is calculated, as shown in Table 2, which is the k-th distance table of each object.
[0127] Table 2
[0128]
[0129] Step 3: Calculate the k-nearest neighbor relationship matrix and reachable distance.
[0130] By constructing the k-nearest neighbor relationship matrix of samples with respect to different attribute subsets, the neighbor relationship between data is described concisely and clearly. The k-nearest neighbor relationship matrix is calculated to obtain:
[0131]
[0132] Taking sample x1 as an example, The first line of Therefore, x1 is related to B h The reachable distance of (h={1,2,3}) is divided into
[0133] Step 4: Construct a set of k nearest neighbor particles and calculate the approximate accuracy.
[0134] By calculating the information granules derived from different attribute subsets, the object characteristics can be described more comprehensively. Select the relative attribute subsets, taking B1 and P1 as examples, according to the k-nearest neighbor relationship matrix and The information particle sets derived from B1 and P1 are:
[0135]
[0136] Therefore, taking x1 as an example, The uncertainty of the information contained in the information granule is measured by calculating the approximate accuracy of the information granule. Taking x1, B1 and P1 as examples, the information granule The approximate accuracy of P1 is:
[0137]
[0138] Similarly, the approximate accuracy of the information particles derived by other objects can be obtained, as shown in Table 3. Table 3 is the approximate accuracy table of particles generated by each object:
[0139] Table 3
[0140]
[0141] Step 5: Calculate the local reachability density.
[0142] The sample density in the information granule is measured by calculating the local reachable density. Taking x1 as an example, the local reachable density of x1 with respect to Bh (h = {1, 2, 3}) is:
[0143]
[0144] Step 6: Calculate the particle size abnormality.
[0145] By calculating the granular abnormality, the degree of abnormality of the information granule is characterized as a screening factor for abnormal points, thereby improving the accuracy of abnormal point screening. Taking x1 as an example, the granular abnormality of x1 with respect to the information granule of Bh (h = {1, 2, 3}) is:
[0146]
[0147] Step 7: Calculate the anomaly score.
[0148] The anomaly score of a sample is calculated by integrating the particle anomaly of the k-nearest neighbor particles of the sample with respect to the selected different attribute subsets. The anomaly score of each sample is calculated as follows:
[0149] kNNAS(x1)=0.0741
[0150] kNNAS(x2)=0.0457
[0151] kNNAS(x3)=0.0770
[0152] kNNAS(x4)=0.0815
[0153] kNNAS(x5)=0.0568
[0154] kNNAS(x6)=0.1407
[0155] Step 8: Perform abnormality determination by comparing the threshold values.
[0156] Comparing the anomaly scores of all objects, it is obvious that the anomaly score of sample x6 is significantly higher than that of other objects. Assuming the anomaly threshold ξ is 0.09, the anomaly scores of all objects are compared with the threshold ξ, and the sample is judged as an outlier.
Claims
1. A method for detecting electricity theft based on k-nearest-neighborhood rough sets, characterized in that: The following steps are involved: S1. Obtaining electricity consumption data, and performing standardized processing on the electricity consumption data to obtain standardized electricity consumption data; S2. According to the normalized electricity consumption data, select an attribute subset and calculate the kth distance of each sample with respect to the attribute subset; S3, according to the k-th distance and k-nearest neighborhood rough set theory, calculate the k-nearest neighborhood relationship matrix and the reachable distance of each sample with respect to the selected attribute subset; S4, constructing a k-neighborhood particle set according to the k-nearest neighbor relationship matrix and calculating the approximate accuracy of each particle; S5. Calculate the local reachability density of each sample according to the reachable distance; S6. Calculate the particle size anomaly of each particle based on the approximate accuracy and the local reachable density; S7, according to the particle anomaly degree, the particle anomaly degree of all samples in the normalized electricity consumption data with respect to the k nearest neighbor particles of the selected different attribute subsets is integrated as the anomaly score of each sample; S8. Determine whether the abnormal score of each sample is greater than a preset threshold value one by one. If yes, output the abnormal point of the electricity consumption data. Otherwise, regard it as a normal point and judge the next sample. Repeat step S8 until all samples are judged.
2. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 1 is characterized in that: The expressions processed by the specification are as follows: Among them, F(f(x,a)) represents the normalization function, f(x,a) represents the value of sample x in the electricity consumption data on attribute a, x represents the sample in the electricity consumption data, max a and min a They represent the maximum and minimum values of sample x with respect to attribute a respectively.
3. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 1 is characterized in that: The step S2 comprises the following steps: S201, selecting attribute subsets based on the normalized electricity consumption data, denoted as B and P; S202, calculate the kth distance of each sample with respect to the attribute subset, where sample x i The k-th distance about attribute subset B is denoted as k-dist B (x i ), which satisfies: There are at least k samples x in the sample set U j ∈U satisfies d B (x i ,x j )≤d B (x i ,x' j ); There are at most k-1 samples x in the sample set U j ∈U satisfies Among them, d B (x i ,x j ) represents the sample x i With sample x j The distance function of attribute subset B, x i 、x j and x' j All represent samples; Sample x i The k-th distance about the attribute subset P is denoted as k-dist P (x i ), which satisfies: There are at least k samples x in the sample set U j ∈U satisfies d P (x i ,x j )≤d P (x i ,x' j ); There are at most k-1 samples x in the sample set U j ∈U satisfies Among them, d P (x i ,x j ) represents the sample x i With sample x j The distance function of about the attribute subset P.
4. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 3 is characterized in that: The step S3 comprises the following steps: S301, according to k-dist B (x), k-dist P (x) and k-nearest-neighbor rough set theory, calculate the k-nearest-neighbor relationship matrix of the sample set U with respect to the attribute subset B and the attribute subset P; S302, according to k-dist B (x i ) and k-dist P (x i ), calculate the reachable distance of each sample with respect to attribute subset B and attribute subset P.
5. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 4 is characterized in that: The expressions of the k-nearest neighbor relationship matrix of the sample set U with respect to the attribute subset B and the attribute subset P are as follows: in, and They represent the k-nearest neighbor relationship matrices of the sample set U with respect to the attribute subset B and the attribute subset P, respectively. Represents the k-nearest neighbor relationship matrix The i-th row and j-th column element of Represents the k-nearest neighbor relationship matrix The i-th row and j-th column element of , n represents the total number of samples; The expressions of the reachable distances of the samples with respect to the attribute subset B and the attribute subset P are as follows: in, Represents sample x i With sample x j Regarding the reachable distance of attribute subset B, Represents sample x i With sample x j The reachability distance for a subset of attributes P.
6. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 1 is characterized in that: The step S4 comprises the following steps: S401, constructing a k-neighborhood particle set according to a k-nearest-neighborhood relationship matrix; S402. Calculate the approximate accuracy of each particle based on the constructed k-neighborhood particle set.
7. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 6 is characterized in that: The expression of the k-neighborhood particle set is as follows: in, and They represent the k-nearest neighbor particle sets derived from attribute subset B and attribute subset P, respectively. and They represent the k-nearest neighbor relationship of the sample set U with respect to the attribute subset B and the attribute subset P, respectively. and Indicates that the sample x i Centered on k-dist B (x i ) and k-dist P (x i ) is the k-nearest neighbor particle of radius, i=1,2,...,n, n is the total number of samples, i is the sample number, U is the sample set, B and P are attribute subsets; The expression of the approximate accuracy of each particle is as follows: in, It means that the sample x i Centered, k-dist B (x i ) is the radius of the k nearest neighbor particles, Indicates that the sample x j Centered, k-dist P (x j ) is the radius of the k nearest neighbor particles, express Regarding the approximate accuracy of the attribute subset P, express The lower approximation of the attribute subset P is: express About the upper approximation of attribute subset P, |*| represents the scale operation, x i and x j All represent samples, represents the set of k nearest neighbor particles derived from the attribute subset P, i and j represent the sample labels, and U represents the sample set.
8. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 1 is characterized in that: The expression of the local reachable density is as follows: Among them, lden B (x i ) represents the local reachability density with respect to attribute subset B, Represents sample x i With sample x j Regarding the reachable distance of attribute subset B, represents the k-nearest neighbor relationship of the sample set U with respect to the attribute subset B, |*| represents the scale operation, It represents the k-nearest neighbor relationship matrix of sample set U with respect to attribute subset B, i and j represent sample numbers, and n represents the total number of samples.
9. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 1 is characterized in that: The expression of the particle abnormality is as follows: in, express The particle size abnormality, lden B (x) represents the local reachability density with respect to attribute subset B, represents k nearest neighbor particles The accuracy of the approximation with respect to a subset P of attributes.
10. The electricity theft detection method based on k-nearest-neighborhood rough sets according to claim 1 is characterized in that: The expression of the anomaly score is as follows: Where kNNAS(x) is the anomaly score, kNNAS(·) is the calculation function of the anomaly score, represents the particle anomaly degree, GAD(·) represents the particle anomaly degree calculation function, m represents the total number of attributes, and h represents the attribute label.
