A leakage detection method based on PCA analysis and RAG

By combining PCA analysis and RAG model, effective noise reduction and dimensionality reduction of residual current signal are achieved, generating accurate leakage probability and structured maintenance solutions. This solves the problems of detection difficulties and maintenance dependence in complex scenarios of existing leakage detection methods, and improves the accuracy and efficiency of leakage detection.

CN122286540APending Publication Date: 2026-06-26NANJING DAQO ELECTRICAL INST CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING DAQO ELECTRICAL INST CO LTD
Filing Date
2026-05-25
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing leakage current detection methods cannot meet the requirements of new power systems for rapid and accurate detection of leakage current faults. In particular, they are difficult to detect when the waveforms are complex and high-frequency components are present in complex scenarios. Furthermore, maintenance relies on human experience and is inefficient. High-dimensional features lead to a decrease in model robustness.

Method used

PCA analysis is used to reduce noise and dimension of the residual current signal. A structured maintenance plan is generated by combining the RAG model. The leakage probability is output by variational mode decomposition, principal component analysis and multiple linear regression model. The abnormality type is determined by combining the meter status parameters. The maintenance plan is automatically generated by the enhanced generative model through incremental learning and retrieval.

Benefits of technology

It significantly improves the accuracy and efficiency of leakage current detection, can handle complex residual current components, has a longer prediction step size and stronger robustness, reduces the technical requirements for personnel, and realizes closed-loop efficient monitoring.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122286540A_ABST
    Figure CN122286540A_ABST
Patent Text Reader

Abstract

This invention provides a leakage current detection method based on PCA analysis and RAG, belonging to the field of energy management and industrial automation technology. It can at least partially solve the problems of existing leakage current detection methods, such as insufficient ability to identify complex residual current components, short prediction step size, poor robustness, and excessively high technical requirements for maintenance personnel. The invention includes: collecting the residual current signal and operating status parameters of the meter; extracting and filtering time-domain and frequency-domain features after noise reduction; obtaining a comprehensive index through principal component analysis for dimensionality reduction; constructing a regression model based on the comprehensive index to output error prediction values; converting these values ​​into leakage current probabilities through a logic function; determining the anomaly type by combining the operating status parameters; inputting the anomaly type into a retrieval enhancement generation model and generating a repair plan based on a maintenance knowledge vector base. This invention balances detection accuracy with engineering applicability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of energy management and industrial automation technology, specifically to a leakage current detection method based on PCA analysis and RAG. Background Technology

[0002] Electrical equipment is widely used in household use, commercial operations, and industrial production. Residual current protection devices (RCDs) are crucial for ensuring public electricity safety, reducing economic losses, and maintaining the safe and stable operation of the power system. RCDs detect residual current to determine if an electric shock fault has occurred in a line. Based on the severity of the fault, the operating time and operating value of the protection device are set in stages to avoid false tripping or failure to trip. In scenarios involving human electric shock, they achieve zero-delay operation to ensure personal safety; in non-human electric shock scenarios, they operate in stages according to the severity of the fault to reduce accident losses.

[0003] However, existing protection methods based on residual current amplitude are no longer adequate for the rapid and accurate detection of leakage faults in modern power systems. Current pulse protection methods frequently fail to operate or maloperate during actual operation, hindering widespread adoption. While amplitude and phase-based residual current protection devices have reduced dead zones compared to current pulse and amplitude comparison devices, their complex structure and setting methods still result in failure to operate. Current separation residual current protection devices are limited in practical application due to the accuracy of their separation algorithms. In grid-connected photovoltaic systems, some faults and unexpected situations often cause residual current waveforms to contain sinusoidal AC components, pulsating DC components, smoothed DC components, and high-frequency components, making the waveform more complex and leading to difficulties in equipment detection and inaccurate judgments. Furthermore, some measures taken to ensure electromagnetic compatibility interfere with the current's shift to ground potential and increase the operating leakage current, with frequencies reaching up to 150kHz. Most existing protection methods do not consider these high-frequency residual current components.

[0004] In the repair process after a leakage current occurs, existing solutions rely on the experience of repair personnel by consulting manuals and fault cases, which requires a high level of technical skill from the repair personnel and results in low efficiency. Moreover, most existing methods rely on static models, whose parameters remain fixed after training. This makes it difficult to continuously learn when faced with dynamically evolving leakage current characteristics, leading to a gradual decline in detection performance.

[0005] Furthermore, in complex leakage current detection scenarios, a large number of time-domain and frequency-domain features are typically extracted to comprehensively reflect the state of the residual current. However, high-dimensional feature parameter sets not only cause the "curse of dimensionality," increasing the computational cost of the model, but also contain a large amount of redundant and collinear information, which reduces the robustness of the model's detection. Therefore, effectively reducing the dimensionality of high-dimensional features (e.g., using Principal Component Analysis, PCA) to extract core indicators is key to improving detection efficiency.

[0006] On the other hand, in the repair process after a leakage occurs, existing solutions rely on the experience of repair personnel to manually consult manuals and fault cases, resulting in low efficiency and high requirements for personnel's technical skills. In recent years, large language models have demonstrated powerful generation capabilities, but directly applying them to the field of industrial maintenance can easily lead to "illusions" (i.e., generating incorrect information). Therefore, there is an urgent need to introduce a generation framework that can combine with professional local knowledge bases (such as Retrieval-Augmented Generation, or RAG for short) to automatically and accurately generate structured repair plans.

[0007] Therefore, designing a leakage current detection method that can handle complex residual current components, has a long prediction step size and strong robustness, and can reduce the technical requirements of maintenance personnel is a technical problem that urgently needs to be solved in the fields of energy management and industrial automation. Summary of the Invention

[0008] The present invention aims to solve at least one of the technical problems existing in the prior art, and to provide a leakage current detection method based on PCA analysis and RAG.

[0009] To achieve the above objectives, this invention provides a leakage current detection method based on PCA analysis and RAG, comprising: Collect the residual current signal and operating status parameters of the meter, reduce the noise of the residual current signal to obtain the noise-reduced residual current signal, and extract the feature parameter set containing time domain feature parameters and frequency domain feature parameters from the noise-reduced residual current signal. The feature parameter set is filtered to obtain a filtered feature parameter set, and principal component analysis is used to reduce the dimensionality of the filtered feature parameter set to obtain a comprehensive index. A regression model is constructed based on the mapping relationship between the comprehensive index and the metering error of the electricity meter. The regression model outputs an error prediction value. The error prediction value is transformed by a logic function to obtain the leakage probability. The abnormality type is determined based on the leakage probability and the operating status parameters. The anomaly type and its associated information are input into the retrieval enhancement generation model, which retrieves relevant context documents from a pre-built maintenance knowledge vector base and generates a maintenance plan based on the relevant context documents.

[0010] Furthermore, after acquiring the residual current signal and before denoising the residual current signal, the method further includes performing data cleaning on the residual current signal. The data cleaning is performed as follows: The 3σ criterion and interquartile range method are used to detect outliers in the residual current signal. The 3σ criterion identifies data exceeding three times the mean standard deviation as outliers. The interquartile range method identifies data meeting the following conditions as outliers: or ; in, Indicating the residual current signal of the first One data point to be detected. The index of the data point. This represents the lower quartile of the residual current signal. This represents the upper quartile of the residual current signal. Indicates interquartile range and ; After deleting the detected outliers, the data is treated as missing data. The total number of missing data is obtained by combining this data with the original missing data in the residual current signal. The percentage of this total missing data relative to the total number of sampling points in a single acquisition cycle of the residual current signal is then calculated to obtain the missing data ratio. Based on this missing data ratio, a filling method is selected. When the missing proportion is less than the first threshold, linear interpolation is used; when the missing proportion is between the first and second thresholds, spline interpolation is used; and when the missing proportion is greater than the second threshold, mean imputation or moving average imputation based on historical data is used.

[0011] Furthermore, the noise reduction of the residual current signal is performed as follows: The residual current signal is decomposed into variational mode decomposition. Given a modal function with finite bandwidth and a center frequency, the constrained variational problem constructed by the variational mode decomposition is: ; in, The index of the modal function and , This represents the total number of the modal functions. Represents a time variable. Indicates the first One modal function, Indicates the first The center frequency of each modal function Represents the Dirac distribution function. Represents the imaginary unit and , Represents pi (π). This represents the convolution operation. This represents the partial derivative operation with respect to the time variable. Denotes the square of the L2 norm. This represents the residual current signal; Introducing a secondary penalty factor and Lagrange multipliers The constrained variational problem is transformed into an unconstrained variational problem, where A preset positive real number greater than zero is used to control the trade-off between data fidelity and the constraints in the constrained variational problem. It is a time-varying Lagrange multiplier function used to maintain the strictness of the constraints; The alternating direction multiplier method is used to iteratively update each mode function, the center frequency, and the Lagrange multiplier; the decomposed... Selective reconstruction is performed on each of the mode functions to remove the noise-dominant mode functions and retain the mode functions corresponding to the useful signal components to obtain the noise-reduced residual current signal.

[0012] Furthermore, the time-domain characteristic parameters include at least one of the following: mean, root mean square value, variance, peak value, peak factor, impulse factor, margin factor, waveform factor, skewness, kurtosis, rectified average value, energy, zero-crossing rate, and kurtosis index. The frequency domain characteristic parameters include at least one of the following: spectral mean, spectral standard deviation, spectral skewness, spectral kurtosis, dominant frequency, dominant frequency amplitude, spectral energy, harmonic component ratio, and the energy proportion of a preset high-frequency band.

[0013] Furthermore, the method for filtering the feature parameter set is as follows: The variance of each feature in the feature parameter set is calculated using the variance selection method. Features with variances greater than a preset variance threshold are selected to form the filtered feature parameter set. The variance is calculated as follows: ; in, This represents a feature in the feature parameter set whose variance is to be calculated. Representation of features variance Represents the total number of samples. The sample number and , Indicates the first Each sample in features The value on, Representation of features In all The mean over a sample.

[0014] Furthermore, the dimensionality reduction of the filtered feature parameter set using principal component analysis is performed as follows: The filtered feature parameter set is subjected to zero-mean and standardization to obtain a standardized matrix. The standardized matrix The number of rows is the total number of samples. The number of columns is the number of feature dimensions of the filtered feature parameter set. ; Calculate the covariance matrix of the normalized matrix: ; in, Let the covariance matrix be denoted as . OK A square array of columns, Represents the normalized matrix The transpose of the matrix, This represents the total number of samples; For the covariance matrix Performing eigenvalue decomposition yields eigenvalues ​​that satisfy the following equation: and the corresponding feature vector : ; in, The indices of the eigenvalues ​​and eigenvectors and , Indicates the first 1 eigenvalue, Indicates the first The eigenvectors corresponding to each eigenvalue; All The feature values ​​are sorted in descending order, and the top features whose cumulative variance contribution rate reaches the preset contribution rate threshold are selected. The eigenvectors corresponding to the eigenvalues ​​constitute the projection matrix. , Indicates the number of selected principal components and , No. The variance contribution rate of each principal component is calculated as follows: ; in, Indicates the first The variance contribution rate of each principal component This represents the number of feature dimensions. For summation index and ; The normalization matrix Project onto the projection matrix to obtain the comprehensive index: ; in, This represents the dimensionality-reduced sample matrix composed of the aforementioned comprehensive indices, which is... OK A matrix of columns.

[0015] Furthermore, the regression model is a multiple linear regression model, and the expression of the regression model is: ; in, This represents the predicted error value. This indicates the number of principal components in the composite index. These respectively represent the 1st to the 1st of the comprehensive indicators. The values ​​of each principal component Represents the intercept term. They represent the 1st to the 1st. The regression coefficients corresponding to each principal component Represents the random error term; The regression coefficients were estimated using the least squares method. ; in, This represents the estimated vector of the regression coefficients. This represents the design matrix of the comprehensive index that includes all samples. Represents the design matrix The transpose of the matrix, Represents the design matrix The corresponding sample error observation vector; The leakage probability is obtained by converting the error prediction value through the logic function as follows: ; in, This indicates the leakage probability. Let be a binary random variable representing whether a leakage event occurs and This indicates that a leakage has occurred. This represents the vector composed of the input comprehensive indicators. The base of the natural logarithm. Indicates the error prediction value and .

[0016] Furthermore, the operating status parameters include the CPU load rate and network communication traffic of the electricity meter. The method for determining the anomaly type based on the leakage probability and the operating status parameters is as follows: When the leakage probability is greater than the first probability threshold, it is determined to be a high leakage risk; when the leakage probability is between the second probability threshold and the first probability threshold, it is determined to be a medium leakage risk; when the leakage probability is less than or equal to the second probability threshold, it is determined to be a low leakage risk. Wherein the first probability threshold is greater than the second probability threshold, and when the leakage probability is less than or equal to the second probability threshold, it is determined to be a low leakage risk, and the abnormal equipment failure or the suspected leakage behavior is not further classified. When the CPU load rate is higher than a preset load threshold and the network communication traffic is lower than a preset traffic threshold, the abnormality type is determined to be a device malfunction; when the CPU load rate is higher than the preset load threshold and the network communication traffic is higher than the preset traffic threshold, the abnormality type is determined to be suspected electricity theft.

[0017] Furthermore, it also includes an incremental update step for the regression model and the logistic function: Whenever a new leakage current case is detected and confirmed, the data of the new leakage current case is added to the training set, and the model parameters are updated using incremental learning. The update expression for incremental learning is: ; in, This indicates the sequence number of the update of the model parameters. Indicates the first Model parameters at the next update Indicates the first The updated model parameters. This represents a preset learning rate that is greater than zero and less than one. This represents the loss function of the regression model or the logistic function. The loss function represents the loss function with respect to the model parameters. gradient, This represents the input feature corresponding to the new leakage current case. This indicates the label corresponding to the new leakage current case; The prediction accuracy and recall of the regression model are monitored online, and the model is retrained when the decrease in prediction accuracy exceeds a preset performance threshold.

[0018] Furthermore, the execution method of the retrieval enhancement generation model generating the maintenance plan is as follows: The maintenance knowledge vector base is constructed by pre-processing text fragmentation and vectorization of maintenance manuals, fault case databases, and technical specifications, wherein the vector representation of text fragments is as follows: ; in, The index for the text segment, Indicates the first A text fragment, This represents the encoding function of the pre-trained language model. Indicates the first The vector obtained by encoding a text segment using the pre-trained language model's encoding function. This represents the dimension of the vector. express 3D real vector space; Convert the anomaly type and its associated information into a query vector. ,in This represents the vector obtained after the anomaly type and its associated information are encoded by the pre-trained language model encoding function. Calculate the cosine similarity between the query vector and each text fragment vector in the maintenance knowledge vector base: ; in, Represents the query vector With the first Text fragment vectors Cosine similarity between them Represents the query vector With the vector The inner product, Represents the query vector L2 norm, Represents the vector The L2 norm; Select the first with the highest similarity A text fragment serves as the relevant context document, wherein A preset positive integer representing the number of text fragments retrieved and greater than zero; The anomaly type, the associated information, and the relevant context documents are assembled according to a preset prompt word template and input into a large language model. The large language model then generates and outputs a structured maintenance plan that includes maintenance steps and suggestions.

[0019] The beneficial effects of this invention are as follows: This invention employs variational mode decomposition to denoise residual current signals, effectively avoiding end-point effects and mode aliasing problems. This allows complex residual current components to retain useful information while suppressing noise, significantly improving the ability to identify complex waveforms containing DC, pulsating, and high-frequency components.

[0020] This invention constructs a three-level feature processing mechanism that includes multidimensional feature extraction in the time and frequency domains, variance selection, and dimensionality reduction using Principal Component Analysis (PCA). This mechanism can significantly compress the high-dimensional feature space while retaining most of the effective signal feature information, eliminating data redundancy and collinearity interference. This balances feature expressiveness with model training efficiency, significantly improving the prediction step size and system robustness of leakage current detection.

[0021] This invention uses a regression model to output error prediction values ​​and transforms them through a logic function to obtain the leakage probability, transforming the leakage fault judgment from a binary qualitative judgment to a probabilistic quantitative assessment, supporting a graded early warning strategy; at the same time, it combines the CPU load rate of the electricity meter and network communication traffic to finely distinguish the abnormal types, which can effectively distinguish between equipment failure and suspected leakage behavior.

[0022] This invention introduces a Retrieval-Augmented Generation (RAG) model and combines it with a pre-built proprietary maintenance knowledge vector base to automatically generate structured maintenance plans. This approach effectively overcomes the technical shortcomings of large language models, which are prone to producing "illusions" in vertical industrial maintenance fields. It significantly reduces the dependence on the technical experience of on-site personnel in leakage current repair, and significantly improves the efficiency, accuracy, and standardization of fault handling.

[0023] This invention employs a model update mechanism that combines incremental learning with periodic retraining, achieving a closed-loop, highly efficient monitoring capability of "predicting leakage and detecting leakage," enabling the method to continuously adapt to the dynamic evolution of leakage characteristics. Attached Figure Description

[0024] Figure 1 This is a flowchart of a leakage current detection method based on PCA analysis and RAG according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the data cleaning and variational mode decomposition noise reduction process according to an embodiment of the present invention; Figure 3 This is a schematic diagram of the principal component analysis feature dimensionality reduction process according to an embodiment of the present invention; Figure 4 This is a schematic diagram illustrating the interaction between the retrieval enhancement generation model and the maintenance knowledge vector base in an embodiment of the present invention. Detailed Implementation

[0025] To make the objectives, technical solutions, and beneficial effects of this application clearer, the following detailed description, in conjunction with the accompanying drawings and specific embodiments, further illustrates this application. It should be understood that the specific embodiments described in this specification are merely for explaining this application and are not intended to limit it.

[0026] The leakage current detection method based on PCA analysis and RAG of this invention is implemented using a leakage current detection system. The leakage current detection system adopts a distributed architecture design, including a group of smart meters deployed on the distribution transformer side, a power management center data server deployed in the regional data center, and an anomaly identification and maintenance support server deployed in the operation and maintenance center. The smart meters are responsible for collecting residual current signals, CPU load rate, and network communication traffic, and uploading them to the data server via HPLC or a private wireless network.

[0027] The power management center's data server receives data uploaded from each smart meter and performs core operations such as data cleaning, variational mode decomposition for noise reduction, feature extraction, principal component analysis for dimensionality reduction, regression modeling, and leakage probability calculation. The anomaly identification and maintenance support server receives the leakage probability and anomaly type determination results, calls the retrieval enhancement generation model to retrieve relevant contextual documents from the maintenance knowledge vector base, generates a structured maintenance plan, and pushes it to the mobile terminals of maintenance personnel.

[0028] Logically, the leakage current detection system comprises seven core components: a data acquisition module, a data preprocessing module, a feature engineering module, a probability prediction module, an anomaly identification module, a retrieval enhancement and generation module, and a model update module. The data acquisition module is deployed on the smart meter side; the data preprocessing and feature engineering modules are deployed on the data server side; the probability prediction and anomaly identification modules are deployed on the anomaly identification server side; the retrieval enhancement and generation module is deployed on the maintenance support server side; and the model update module spans both the data server and the maintenance support server, undertaking the responsibility of closed-loop feedback.

[0029] The data acquisition module collects analog residual current signals through a built-in residual current transformer. After filtering out power frequency interference by a signal conditioning circuit, the signals are digitized and stored by a high-speed analog-to-digital converter. Simultaneously, the meter's built-in operation monitoring unit collects two operational status parameters: CPU load rate and network communication traffic. The data preprocessing module performs data cleaning and variational mode decomposition (VMD) noise reduction upon receiving the raw residual current signal. The feature engineering module extracts time-domain and frequency-domain feature parameters from the denoised residual current signal and sequentially performs variance screening and principal component analysis (PCA) dimensionality reduction. The probability prediction module constructs a multiple linear regression model based on the principal component comprehensive index and outputs the leakage probability through a logic function transformation. The anomaly identification module determines the anomaly type by combining the leakage probability and operational status parameters. The retrieval enhancement generation module automatically generates maintenance plans by calling a large language model and vector database. The model update module maintains model performance through incremental learning and periodic retraining.

[0030] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0031] Example 1 This embodiment uses a leakage current monitoring scenario in a residential community within a city's power distribution network as its application scenario. The community has 500 smart meters of the same model, distributed across 20 buildings. The community uses a three-phase four-wire power supply system. Some residents have photovoltaic inverters, variable frequency air conditioners, LED lighting, and other non-linear loads connected to their homes, resulting in residual current waveforms containing numerous high-frequency and harmonic components.

[0032] See Figure 1 The leakage current detection method in this embodiment includes the following steps: Step S1: Acquisition of residual current signal and operating status parameters.

[0033] Each smart meter collects residual current signals in real time through its built-in residual current transformer. The sampling frequency is set to 10kHz, and the sampling duration is set to 2 seconds. Each sampling collects 20,000 sampling points to form a residual current record. Simultaneously, the smart meter collects two operating status parameters—CPU load rate and network communication traffic—through its own operation monitoring unit. The sampling period for CPU load rate is set to 1 second, with the unit being percentage; the sampling period for network communication traffic is set to 1 second, with the unit being KB per second.

[0034] Every 5 minutes, the smart meters record the residual current and operating status parameters they collect, uploading them to the power management center's data server via the HPLC communication link. The data server stores the data from 500 smart meters in time-aligned format, providing data support for subsequent analysis.

[0035] Step S2: Data cleaning.

[0036] See Figure 2During the acquisition of residual current signals, errors and missing values ​​often exist in the raw data due to sensor malfunctions, communication interference, equipment abnormalities, and other reasons. The data server first performs data cleaning on the uploaded residual current signals.

[0037] The first step is outlier detection and removal. A dual detection method using the 3σ criterion and the interquartile range is employed. The 3σ criterion identifies data points exceeding three standard deviations above or below the mean as outliers. The interquartile range method identifies data points meeting the following criteria as outliers: or ; in, The lower quartile, It is the upper quartile. The interquartile range is used. Detected erroneous values ​​are deleted and treated as missing values.

[0038] The second step is missing value imputation. Specifically, the system calculates the total number of missing data by summing the number of deleted outliers in a single residual current record (i.e., out of 20,000 sampling points) with the number of missing values ​​caused by the original network packet loss. This total number of missing data is then divided by the total number of sampling points (20,000) to calculate the missing percentage. Different imputation methods are selected based on the missing percentage. In this embodiment, the first threshold is set to 5%, and the second threshold is set to 15%. When the missing percentage is less than 5%, linear interpolation is used. ; When the missing data ratio is between 5% and 15%, cubic spline interpolation is used, and the continuity of the second derivative of the interpolation curve is ensured by constructing a piecewise cubic polynomial. When the missing data ratio is greater than 15%, moving average imputation based on nearby time-series data is used. ; in, The length of the sliding window is set to 10 in this embodiment.

[0039] In one round of data collection in this embodiment, 23 abnormal points were detected in the residual current record uploaded by meter number R0128, accounting for 0.12%. After filling in the abnormal points using linear interpolation, a complete residual current signal was obtained.

[0040] Step S3: Variational mode decomposition and noise reduction.

[0041] Residual current signals often face severe noise interference in practical applications, with high-frequency electromagnetic compatibility interference components reaching up to 150kHz. To ensure signal accuracy, this embodiment employs variational mode decomposition (VMD) to denoise the residual current signal. VMD can effectively reduce noise while retaining a large amount of valid information in the signal by selecting appropriate decomposition parameters.

[0042] Assuming the original input signal It can be broken down into Modal functions Each mode has a finite bandwidth and center frequency. Then the variational problem can be expressed as: ; in, Represents the decomposed A set of modalities This represents the set of center frequencies for each mode. Let be the Dirac distribution function. It is the imaginary unit.

[0043] Introducing a secondary penalty factor and Lagrange multipliers Then, the constrained variational problem is transformed into an unconstrained variational problem: ; The optimization problem is solved using the alternating direction multiplier method, with iterative updates. , and : ; ; ; in, This is a noise tolerance parameter. This represents the number of iterations.

[0044] In this embodiment, the optimal number of modes is determined by the center frequency observation method. The penalty factor is 5. Set to 2500, noise tolerance parameter The value was set to 0.01. Five intrinsic mode functions (IMFs) were obtained, from IMF1 to IMF5. IMF4 and IMF5 mainly contained high-frequency noise components above 100kHz, which were removed. IMF1 to IMF3 were retained as useful signal components, and the denoised residual current signal was reconstructed. The signal-to-noise ratio of the reconstructed signal was improved by approximately 12dB compared to the original signal.

[0045] Step S4: Time-domain and frequency-domain feature extraction.

[0046] A feature parameter set containing 14 time-domain feature parameters and 8 frequency-domain feature parameters was extracted from the residual current signal after noise reduction.

[0047] The formulas for calculating the 14 time-domain characteristic parameters are as follows: mean : This represents the average level of the signal; Root mean square value : This reflects the effective value of the signal; variance : This indicates the degree of signal fluctuation; peak : The maximum absolute value of the signal; Peak factor : The ratio of peak value to effective value; Pulse factor : The ratio of the peak value to the absolute mean; margin factor : The ratio of the peak value to the root mean; Waveform factor : The ratio of the effective value to the absolute mean; Skewness : This measures the symmetry of signal distribution. Kudo : This measures the sharpness of the signal distribution. Rectified average value : ; energy : ; Zero crossing rate ; kurtosis index : ,in .

[0048] The formulas for calculating the eight frequency domain characteristic parameters are as follows: Spectral mean : ; Spectrum Standard Deviation : ; Spectral skewness : ; Spectral kurtosis : ; main frequency : ; main frequency amplitude : ; Spectral Energy : ; Harmonic component ratio : .

[0049] In this embodiment, the above 22 characteristic parameters are calculated on the residual current signal after noise reduction, forming a feature parameter set with a dimension of 22.

[0050] Step S5: Feature selection using variance selection method.

[0051] The variance selection method is used to filter the feature parameter set. The variance of each feature is calculated; a smaller variance indicates that the feature's variation is less significant and its contribution to classification is smaller. The formula for calculating variance is: ; in, Features The mean, This represents the sample size. In this embodiment, the preset variance threshold is 0.01, and features with a variance greater than 0.01 are selected.

[0052] After screening, 13 features with high relevance to residual current identification were retained from the 22 feature parameters, including: mean, root mean square value, variance, peak value, peak factor, impulse factor, skewness, kurtosis, spectral mean, spectral standard deviation, dominant frequency, dominant frequency amplitude, and harmonic component ratio. Features that were mainly removed were those with small variations in margin factor and waveform factor under different leakage current scenarios.

[0053] Step S6: Principal Component Analysis (PCA) Dimensionality Reduction.

[0054] See Figure 3 Principal component analysis (PCA) is then performed on the filtered feature parameter set to reduce dimensionality and obtain a comprehensive index. The basic process of PCA is as follows: The first step is data standardization. This involves standardizing the original feature matrix. Perform zero-mean normalization: Further implement Z-score standardization: ,in Let be the mean vector of each feature. Let be the standard deviation vector of each feature.

[0055] The second step is to calculate the covariance matrix: ; The third step is eigenvalue decomposition. This involves the covariance matrix... Perform eigenvalue decomposition: ; in, For eigenvalues, This is the corresponding feature vector.

[0056] The fourth step is sorting and selection. Sort the feature values ​​from largest to smallest. Before choosing The eigenvectors corresponding to the largest eigenvalues ​​form the projection matrix. .

[0057] Step 5: Calculate the variance contribution rate: ; Step 6, Dimensional Reduction Projection: .

[0058] This embodiment selects the top performers with a cumulative variance contribution rate of 85% or higher. Of the principal components, the first four were selected, with a cumulative variance contribution rate of 87.6%. These four principal components can be summarized as: equipment and line integrity, human intervention and behavioral characteristics, monitoring system reliability, and load characteristics and interference. Ultimately, four comprehensive indicators were obtained. As input for regression modeling.

[0059] Step S7: Multiple linear regression modeling and leakage probability calculation.

[0060] A multiple linear regression model was constructed based on the mapping relationship between four comprehensive indicators and the metering error: ; in, This is the predicted error value. For the intercept term, For regression coefficients, This is the random error term.

[0061] The regression coefficients were estimated using the least squares method: ; Model evaluation metrics include: coefficient of determination ,in For the sum of squared residuals, The sum of squares; mean square error Mean absolute error .when and At that time, the model was considered to have a good fit. This embodiment, after training... Reached 0.89, The value is 0.032, indicating a good model fit.

[0062] The leakage current probability is transformed using a logic function: ; in, .

[0063] Step S8: Exception type determination.

[0064] The type of anomaly is determined by combining the leakage current probability, the meter's CPU load rate, and network communication traffic. The leakage current probability threshold is set as follows: First probability threshold. Second probability threshold .when When it is judged as a high risk of leakage; when When it is determined to be a medium risk of leakage; when It was determined to have a low risk of leakage.

[0065] The detailed rules for determining abnormal types are as follows: The preset CPU load rate threshold is 150% of the average value of the same model of electricity meter, and the preset network communication traffic threshold is 150% of the average value of the same model of electricity meter. When the CPU load rate exceeds the threshold but the network communication traffic is normal, it is determined to be an equipment malfunction; when both the CPU load rate and the network communication traffic exceed the threshold, it is determined to be suspected electricity theft.

[0066] In this embodiment, three high-risk smart meters were identified among 500 smart meters: meter R0128 had a CPU load rate as high as 92% (average of 35% for the same model), but normal network communication traffic, and was determined to be an abnormal device malfunction; meter R0351 had a CPU load rate of 85% and network communication traffic as high as 180% of the average for the same model, and was determined to be suspected of electricity theft; meter R0472 had both parameters exceeding the threshold, and was also determined to be suspected of electricity theft.

[0067] Step S9: Incremental learning and updating.

[0068] Whenever a new leakage current case is detected and confirmed on-site, the case data is added to the training set, and the model parameters are updated using incremental learning. ; in, For model parameters, For learning rate, The gradient of the loss function. This is for new sample data. The learning rate in this example is... Set to 0.001.

[0069] Every month, the model is retrained using all accumulated data to eliminate the cumulative bias that may result from incremental learning. The model's prediction accuracy and recall are monitored in real time, and a model update is triggered when the prediction accuracy drops by more than 5%. Historical model versions are saved, allowing for quick rollback to a stable version if a new version performs poorly.

[0070] Step S10: Retrieve the Enhanced Generative (RAG) model to generate a repair plan.

[0071] To address the technical problem that large language models are prone to 'illusion' in specific industrial maintenance fields due to the lack of private data, this embodiment constructs a RAG architecture.

[0072] See Figure 4 For abnormal electricity meters, the enhanced generative model is used to automatically generate a repair plan. The specific implementation method is as follows: The first step is to construct a maintenance knowledge vector base. Maintenance manuals, fault case libraries, technical specifications, and other documents undergo text segmentation and vectorization processing, and are then stored in a vector database. Text vectorization uses the pre-trained language model BERT, and the vector representation is as follows: ,in For the first A text fragment, In this embodiment, the dimension is vector. .

[0073] The second step is query vector generation. The detected anomaly information is organized into query text, including meter number, leakage probability, anomaly type, and anomaly feature parameters, and then converted into query vectors using the same pre-trained language model. .

[0074] The third step is similarity retrieval. This involves calculating the cosine similarity between the query vector and the document vectors in the vector database. ; Step 4: Top-K sorting. Select the top K results with the highest similarity. Each document fragment serves as a relevant context document in this embodiment. .

[0075] Step 5: Large Model Generation. The relevant context documents and anomaly descriptions are assembled according to the prompt word template and input into the large language model. The prompt word template is: "Based on the following fault information: {anomaly description}, and referring to the maintenance manual content: {document search}, please provide detailed troubleshooting steps and suggestions." The large language model outputs a structured troubleshooting plan containing troubleshooting steps and suggestions.

[0076] Step 6: Solution Output and Feedback. The generated maintenance solution is presented to maintenance personnel in structured JSON format. Simultaneously, feedback on maintenance results is collected to optimize the maintenance knowledge vector base and retrieval strategy. For meter R0128, which is malfunctioning, the recommended maintenance steps by the enhanced retrieval model include: checking the meter's CPU module heat dissipation, verifying the firmware version, and troubleshooting communication module anomalies. For meter R0351, suspected of leakage, the recommended maintenance steps include: investigating the metering circuit, verifying the current transformer, and detecting strong magnetic interference.

[0077] In summary, this embodiment employs variational mode decomposition to reduce noise in the residual current signal, uses variance selection combined with principal component analysis for dimensionality reduction, employs multiple linear regression combined with logic functions to output leakage probability, and automatically generates maintenance plans through a retrieval-enhanced generative model. In an application scenario involving 500 meters in a city's power distribution network, the detection accuracy reaches over 95%.

[0078] Example 2 This embodiment uses the leakage current monitoring scenario of electrical equipment in an industrial park as an application scenario. The industrial park covers a total area of ​​approximately 800,000 square meters and includes various load types such as machining, chemical manufacturing, and data center computer rooms. A total of 120 intelligent residual current protection devices are deployed in the park, covering two specifications: 60 units for end protection of workshop distribution cabinets and 60 units for main protection of office buildings. The operating environment of electrical equipment is harsh, including high temperature, high humidity, and corrosive chemical gases. The time-varying characteristics and high-frequency components of the residual current are significant. In addition, some workshops in the park have highly nonlinear loads such as frequency converters and high-power welding machines, causing the residual current waveform to simultaneously contain multiple components such as fundamental wave, harmonics, spike pulses, and high-frequency noise.

[0079] See Figure 1 The leakage current detection method in this embodiment includes the following steps: Step S1: Acquisition of residual current signal and operating status parameters.

[0080] Each intelligent residual current protection device collects residual current signals in real time through its built-in residual current transformer. Considering the higher frequency of electromagnetic compatibility interference in industrial scenarios, the sampling frequency is set to 20kHz, and the sampling duration is set to 1 second. Each collection yields 20,000 sampling points, forming a residual current record. Simultaneously, the device collects two operating status parameters: CPU load rate and network communication traffic. The sampling period for CPU load rate is set to 1 second, expressed as a percentage; the sampling period for network communication traffic is set to 500 milliseconds, expressed as KB per second.

[0081] Every 2 minutes, 120 devices upload their residual current records and operating status parameters to the power management center data server in the park's data center via an industrial Ethernet link. The data server stores the data from the 120 devices in time-aligned format and categorizes it into four data sets based on the device's region and model.

[0082] Step S2: Data cleaning.

[0083] See Figure 2The interference with the raw residual current signal in the industrial park environment is more severe than in residential scenarios, with the average proportion of detected error and missing values ​​reaching 0.8%. The data server first performs data cleaning on the uploaded residual current signal.

[0084] The first step is outlier detection and removal. A dual detection method using the 3σ criterion and the interquartile range is employed. The 3σ criterion identifies data points exceeding three standard deviations above or below the mean as outliers. The interquartile range method identifies data points meeting the following criteria as outliers: or ; in, The lower quartile, It is the upper quartile. The interquartile range is used. Detected erroneous values ​​are deleted and treated as missing values.

[0085] The second step is missing value imputation. In this embodiment, the first threshold is also set to 5%, and the second threshold is also set to 15%. When the missing value ratio is less than 5%, linear interpolation is used. ; Cubic spline interpolation is used when the missing data ratio is between 5% and 15%. When the missing data ratio is greater than 15%, a moving average based on nearest-time data is used for imputation. ; in, The sliding window length is determined in this embodiment. Considering the higher sampling rate and the need for real-time performance in industrial scenarios, the actual length is [not specified]. Set it to 15.

[0086] In one round of data collection in this embodiment, 156 abnormal points were detected in the records uploaded by the residual current protection device in the chemical workshop, numbered G015, accounting for 0.78%, which were filled using linear interpolation. The equipment in the computer room, numbered G072, experienced a short communication interruption during this period, resulting in a missing rate of 8.3%, which was filled using cubic spline interpolation to obtain a complete residual current signal.

[0087] Step S3: Variational mode decomposition and noise reduction.

[0088] In industrial park scenarios, strong nonlinear loads and electromagnetic compatibility interference make the high-frequency noise components in the residual current signal more abundant. This embodiment uses variational mode decomposition to reduce noise in the residual current signal. Compared with embodiment one, the parameter selection needs to further increase the number of modes and improve the penalty factor value.

[0089] Assuming the original input signal It can be broken down into Modal functions Each mode has a finite bandwidth and center frequency. Then the variational problem can be expressed as: ; Introducing a secondary penalty factor and Lagrange multipliers The constrained variational problem is transformed into an unconstrained variational problem, and the alternating direction multiplier method is used for iterative solution. The iterative update formula is consistent with that in Example 1.

[0090] In this embodiment, the optimal number of modes is determined by the center frequency observation method. The penalty factor is 8. Set to 3000, noise tolerance parameter The value was set to 0.01. Eight intrinsic mode functions (IMFs) were obtained, from IMF1 to IMF8. IMF6 to IMF8 primarily exhibited high-frequency noise components around 150kHz, with IMF6 having a center frequency of approximately 65kHz, IMF7 approximately 110kHz, and IMF8 approximately 148kHz. Spectrum analysis confirmed these as electromagnetic compatibility interference and switching device noise, which were then eliminated. IMF1 to IMF5 were retained as useful signal components, and the reconstructed signal yielded the denoised residual current signal. The signal-to-noise ratio of the reconstructed signal was improved by approximately 15dB compared to the original signal.

[0091] Step S4: Time-domain and frequency-domain feature extraction.

[0092] Fourteen time-domain feature parameters and eight frequency-domain feature parameters were extracted from the noise-reduced residual current signal, for a total of 22 feature parameters. The calculation formulas for each time-domain and frequency-domain feature parameter are completely consistent with those in Example 1.

[0093] The 14 time-domain feature parameters include: mean Root mean square value ,variance Peak Peak factor Pulse factor Margin factor Waveform factor skewness kurtosis , Rectified average value ,energy Zero crossing rate and kurtosis index .

[0094] The eight frequency domain characteristic parameters include: spectral mean Spectrum standard deviation Spectral skewness Spectral kurtosis Main frequency , main frequency amplitude Spectral energy Harmonic component ratio .

[0095] It should be noted that, due to the prevalence of nonlinear loads such as frequency converters in industrial settings, the extracted harmonic components are more... and spectral energy The data showed a significantly elevated level, which provided prior evidence for subsequent feature screening to identify features with strong diagnostic value.

[0096] Step S5: Feature selection using variance selection method.

[0097] The variance selection method is used to filter the feature parameter set, and the variance calculation formula is the same as in Example 1: ; Considering the difference between the distribution of feature variance in industrial scenarios and that in residential scenarios, this embodiment adjusts the preset variance threshold to 0.015 to filter features with variance greater than 0.015.

[0098] After screening, 12 features with high relevance to residual current identification were retained from the 22 feature parameters, including: mean, root mean square value, variance, peak value, peak factor, impulse factor, skewness, kurtosis, spectral standard deviation, dominant frequency, dominant frequency amplitude, and harmonic component ratio. Compared to Example 1, waveform factor was removed because the waveform shape of residual current signals in industrial scenarios varies little under different operating conditions, and waveform factor has limited ability to distinguish anomalies.

[0099] Step S6: Principal Component Analysis (PCA) Dimensionality Reduction.

[0100] See Figure 3 Principal component analysis (PCA) is performed on the filtered feature parameter set to reduce dimensionality and obtain a comprehensive index. The basic process of PCA is consistent with that in Example 1, consisting of six steps: data standardization, covariance matrix calculation, eigenvalue decomposition, eigenvalue sorting and selection, variance contribution rate calculation, and dimensionality reduction projection.

[0101] The formula for calculating the covariance matrix is: ; The eigenvalue decomposition formula is The formula for calculating the variance contribution rate is: The dimensionality reduction projection formula is: .

[0102] Considering that the causes of leakage current in industrial settings are more diverse than in residential settings, this embodiment raises the cumulative variance contribution rate threshold to 90%. After calculation, the top 5 principal components were selected, with a cumulative variance contribution rate of 91.2%. These 5 principal components can be summarized as: equipment insulation integrity, environmental corrosion, human intervention and behavioral characteristics, load harmonic characteristics, and the reliability of the monitoring system itself. Finally, 5 comprehensive indicators are obtained. As input for regression modeling.

[0103] Step S7: Multiple linear regression modeling and leakage probability calculation.

[0104] A multiple linear regression model is constructed based on the mapping relationship between five comprehensive indicators and the metering error of residual current protection devices: ; in, This is the predicted error value. For the intercept term, For regression coefficients, This represents the random error term. The regression coefficients are estimated using the least squares method. ; The coefficient of determination in this embodiment after training The mean square error reached 0.87. The mean absolute error is 0.041. The value is 0.035, which satisfies the condition. and The model fit requirement.

[0105] The leakage current probability is transformed using a logic function: ; in, .

[0106] Step S8: Exception type determination.

[0107] The anomaly type is determined by combining the leakage current probability with the CPU load rate and network communication traffic of the residual current protection device. The leakage current probability threshold is set using the parameters from Example 1: First probability threshold. Second probability threshold .when When it is judged as a high risk of leakage; when When it is determined to be a medium risk of leakage; when It was determined to have a low risk of leakage.

[0108] The refined rules for determining anomalies have been adapted to the characteristics of industrial scenarios: Considering the large fluctuations in electricity meter loads in industrial parks, the preset CPU load rate threshold has been adjusted to 200% of the average value of the same model of device, and the preset network communication traffic threshold has been adjusted to 180% of the average value of the same model of device. When the CPU load rate exceeds the threshold but the network communication traffic is normal, it is determined to be an equipment malfunction; when both the CPU load rate and the network communication traffic exceed the threshold, it is determined to be suspected electricity theft.

[0109] In this embodiment, 5 devices with high leakage risk were identified out of 120 intelligent residual current protection devices: Device G015 had a CPU load rate of 96% (average of 42% for the same model), but normal network communication traffic, indicating an abnormal device malfunction. On-site inspection revealed a blocked CPU cooling module. Device G041 had a CPU load rate of 88% and network communication traffic that was 215% of the average for the same model, indicating suspected leakage. On-site verification revealed that the current transformer was covered by a metal object. Device G072 had a leakage probability of 0.82, a CPU load rate of 89%, and normal network communication traffic, indicating an abnormal device malfunction. Devices G098 and G113 were also identified as suspected leakage. The accuracy of the identification results for these 5 devices was confirmed to be 100% after verification by on-site maintenance personnel.

[0110] Step S9: Incremental learning and updating.

[0111] Whenever a new leakage current case is detected and confirmed on-site, the case data is added to the training set, and the model parameters are updated using an incremental learning method. The update formula is the same as in Example 1: ; Considering the rapid changes in equipment operating status and the fast accumulation of cases in industrial scenarios, the learning rate in this embodiment is... The value was set to 0.0005, smaller than in Example 1, to ensure the stability of model updates. The periodic retraining cycle was shortened from one month to two weeks, enabling the model to respond more quickly to rapid changes in the operating status of industrial equipment. Real-time monitoring of model prediction accuracy, recall, and other metrics was implemented, triggering a model update when prediction accuracy dropped by more than 5%. Nearly six historical model versions were retained for rollback purposes.

[0112] Step S10: Retrieve the Enhanced Generative (RAG) model to generate a repair plan.

[0113] See Figure 4 For malfunctioning devices, the enhanced generative model is used to automatically generate maintenance plans. The specific implementation method is as follows: The first step is to construct a maintenance knowledge vector base. Compared to the residential scenario vector base in Example 1, this example's vector base additionally includes an industrial scenario maintenance experience base, professional technical procedure documents, a chemical corrosion protection manual, and a frequency converter fault case set. The total number of document fragments has increased from over 5,000 in Example 1 to over 12,000. Text vectorization uses the pre-trained language model BERT, and the vector representation is as follows: ,in .

[0114] The second step is query vector generation. The detected anomaly information is organized into query text, including device number, workshop, leakage probability, anomaly type, CPU load rate deviation, network communication traffic deviation, and anomaly characteristic parameters. This text is then converted into query vectors using the same pre-trained language model. .

[0115] The third step is similarity retrieval. This involves calculating the cosine similarity between the query vector and the document vectors in the vector database. ; The fourth step is Top-K sorting. Considering the more diverse causes of failures in industrial scenarios, the top K sorting results are selected based on the highest similarity. Each document fragment serves as a relevant context document in this embodiment. Set it to 8.

[0116] Step 5: Large Model Generation. The relevant context documents and anomaly descriptions are assembled according to a preset prompt word template and input into the large language model. The prompt word template is: "Based on the following industrial scenario fault information: {anomaly description}, and referring to the maintenance manual content: {document search}, please provide detailed maintenance steps, safety precautions, and suggestions according to industrial safety regulations." The large language model outputs a structured maintenance plan containing maintenance steps, safety precautions, and suggestions.

[0117] Step 6: Solution Output and Feedback. The generated maintenance solution is pushed to the industrial rugged tablet terminal of the maintenance personnel in structured JSON format. For the faulty device G015, the maintenance steps recommended by the enhanced generation model include: shutting down the device and performing electrical isolation, checking the dust accumulation on the CPU module heatsink, cleaning the heat dissipation channel, verifying the CPU firmware version, and performing a continuous 72-hour aging test. For the suspected leakage device G041, the recommended maintenance steps include: power off operation, disassembling and inspecting the current transformer, checking for metal adsorption on the outside of the transformer, measuring the magnetic saturation characteristics of the transformer, and verifying the metering circuit wiring. The average maintenance time is reduced by about 40% compared to the method of relying on manual manual lookup, and the one-time accuracy rate of the maintenance solution is improved from 72% in the traditional method to 91%.

[0118] In summary, this embodiment employs variational mode decomposition to reduce noise in the residual current signal, uses variance selection combined with principal component analysis for dimensionality reduction, employs multiple linear regression combined with logic functions to output leakage probability, and automatically generates maintenance plans through a retrieval-enhanced generative model. In an application scenario involving 120 residual current protection devices in an industrial park, the detection accuracy reached 100%, and maintenance efficiency was significantly improved.

[0119] Example 3 This embodiment uses a leakage current monitoring scenario in a grid-connected photovoltaic power plant as an example. The power plant has an installed capacity of 50MW, covers approximately 800 acres, and includes 200 string photovoltaic inverters, each with a capacity of 250kW. The power plant's electrical system is connected to a 110kV substation. The leakage current composition in a grid-connected photovoltaic system is extremely complex, containing not only sinusoidal AC components and pulsating DC components, but also smoothed DC components generated by the switching actions of the photovoltaic inverters and high-frequency components with frequencies up to 150kHz. Furthermore, the grounding of the photovoltaic module backsheet and the presence of common-mode current make the residual current waveform more complex than in typical scenarios, posing a greater challenge to the identification of residual current protection devices.

[0120] See Figure 1 The leakage current detection method in this embodiment includes the following steps: Step S1: Acquisition of residual current signal and operating status parameters.

[0121] Each photovoltaic inverter has a built-in residual current transformer that collects residual current signals in real time. Considering that high-frequency components can reach 150kHz in photovoltaic scenarios, the sampling frequency is increased to 50kHz to fully satisfy the Nyquist sampling theorem, and the sampling duration is set to 500 milliseconds. Each acquisition yields 25,000 sampling points, forming a residual current record. Simultaneously, two operating status parameters are collected: inverter CPU load rate and network communication traffic. The CPU load rate sampling period is 1 second, and the network communication traffic sampling period is 500 milliseconds.

[0122] Every 3 minutes, 200 photovoltaic inverters upload their residual current records and operating status parameters to the data acquisition server at the power plant site via a dedicated fiber optic network. The data is then forwarded to the power management center data server at the power generation group headquarters. The data server categorizes and stores the data according to two dimensions: inverter geographical region and photovoltaic module model.

[0123] Step S2: Data cleaning.

[0124] See Figure 2 In photovoltaic scenarios, the errors and missing values ​​in the raw data mainly originate from communication link interference and instantaneous sampling distortion during inverter switching.

[0125] The first step is outlier detection and removal. A dual detection method using the 3σ criterion and the interquartile range (ICM) is employed. The ICM criteria for identifying outliers are as follows: or ; in, The lower quartile, It is the upper quartile. The interquartile range is used. Detected erroneous values ​​are deleted and treated as missing values.

[0126] The second step is missing value imputation. Considering the higher requirements for data integrity in photovoltaic scenarios, this embodiment tightens the first threshold to 3% and the second threshold to 12%. When the missing value ratio is less than 3%, linear interpolation is used. ; Cubic spline interpolation is used when the missing percentage is between 3% and 12%. When the missing percentage is greater than 12%, a moving average based on nearest-time data is used for imputation. ; Sliding window length Set it to 20 to accommodate noise smoothing requirements at higher sampling rates.

[0127] In one round of data collection in this embodiment, 420 abnormal points were detected in the residual current record uploaded by photovoltaic inverter P078, accounting for 1.68%, which were filled using linear interpolation. Inverter P142 had a missing rate of 9.7% due to an inverter restart during this period, which was filled using cubic spline interpolation to obtain a complete residual current signal.

[0128] Step S3: Variational mode decomposition and noise reduction.

[0129] In photovoltaic grid-connected scenarios, the high-frequency components of the residual current signal are dense and there are multiple dispersed center frequencies. In this embodiment, the variational mode decomposition method is used to reduce the noise of the residual current signal, and the parameter selection is further enhanced compared with the second embodiment.

[0130] The variational problem is expressed as: ; Introducing a secondary penalty factor and Lagrange multipliers Then, the constrained variational problem is transformed into an unconstrained variational problem, and the alternating direction multiplier method is used for iterative solution.

[0131] In this embodiment, the optimal number of modes is determined by the center frequency observation method. The penalty factor is 10. Set to 3500, noise tolerance parameter The value was set to 0.005. Ten intrinsic mode functions (IMFs) were obtained, from IMF1 to IMF10. IMF7 to IMF10 primarily exhibited high-frequency noise components above 100kHz, which were identified as photovoltaic inverter switching noise and electromagnetic compatibility interference through spectral analysis and were therefore eliminated. IMF1 to IMF6 were retained as useful signal components. The signal-to-noise ratio of the reconstructed signal was improved by approximately 18dB compared to the original signal.

[0132] Step S4: Time-domain and frequency-domain feature extraction.

[0133] Fourteen time-domain feature parameters and eight frequency-domain feature parameters are extracted from the noise-reduced residual current signal, totaling 22 general feature parameters. In addition, to address the specific characteristics of photovoltaic scenarios, this embodiment adds two photovoltaic-specific features: the proportion of DC component. Energy percentage of the 150kHz band The formulas for calculating the two specific features are: ; ; in, The mean of the signal. The root mean square value of the signal. The signal's spectral amplitude, and the accumulation range. kHz represents a frequency point greater than or equal to 100kHz. The calculation formulas for the general time-domain characteristic parameters and frequency-domain characteristic parameters are completely consistent with those in Example 1. The final extracted feature parameter set contains a total of 24 feature parameters.

[0134] Step S5: Feature selection using variance selection method.

[0135] The variance selection method is used to filter the feature parameter set. Considering that the distribution pattern of feature variance in photovoltaic scenarios differs from that in residential and industrial scenarios, this embodiment further adjusts the preset variance threshold to 0.008, filtering features with variance greater than 0.008. The variance calculation formula is the same as in Embodiment 1: ; After screening, 15 features with high relevance to residual current identification were retained from 24 feature parameters. These features include: mean, root mean square value, variance, peak value, peak factor, impulse factor, skewness, kurtosis, spectral mean, spectral standard deviation, dominant frequency, dominant frequency amplitude, harmonic component ratio, DC component ratio, and 150kHz frequency band energy ratio. The retention of the two photovoltaic-specific features, DC component ratio and 150kHz frequency band energy ratio, indicates that these two features have strong discriminative power for identifying leakage current in photovoltaic scenarios.

[0136] Step S6: Principal Component Analysis (PCA) Dimensionality Reduction.

[0137] See Figure 3 Principal component analysis (PCA) is then performed on the filtered feature parameter set to reduce dimensionality and obtain a comprehensive index. The basic process of PCA is consistent with that in Example 1, which involves six steps in sequence: data standardization, covariance matrix calculation, eigenvalue decomposition, eigenvalue sorting and selection, variance contribution rate calculation, and dimensionality reduction projection.

[0138] The main formulas include the calculation of the covariance matrix. Eigenvalue decomposition Variance contribution rate and dimensionality reduction projection .

[0139] Considering that leakage current causes in photovoltaic scenarios involve multiple dimensions such as equipment, cables, photovoltaic modules, inverters, and the environment, this embodiment sets the cumulative variance contribution rate threshold to 88%. After calculation, the first six principal components were selected, resulting in a cumulative variance contribution rate of 89.3%. These six principal components can be summarized as follows: photovoltaic inverter insulation state, DC-AC coupling characteristics, high-frequency electromagnetic compatibility interference characteristics, diurnal load fluctuation characteristics, cable aging and mechanical damage characteristics, and monitoring system accuracy characteristics. Ultimately, six comprehensive indicators are obtained. As input for regression modeling.

[0140] Step S7: Multiple linear regression modeling and leakage probability calculation.

[0141] A multiple linear regression model is constructed based on the mapping relationship between six comprehensive indicators and the metering error of photovoltaic inverters: ; in, This is the predicted error value. For the intercept term, For regression coefficients, This represents the random error term. The regression coefficients are estimated using the least squares method. ; The coefficient of determination in this embodiment after training The mean square error reached 0.86. The mean absolute error is 0.047. The goodness of fit is 0.039, which basically meets the requirements for model fit. Due to the strong nonlinear characteristics of photovoltaic scenarios, the goodness of fit of the model is slightly lower than that of residential scenarios, but it has reached the level of engineering usability.

[0142] The leakage current probability is transformed using a logic function: ; in, .

[0143] Step S8: Exception type determination.

[0144] The anomaly type is determined by combining the leakage current probability with the CPU load rate of the photovoltaic inverter and network communication traffic. Given the significant day-night load differences in photovoltaic scenarios, the inverter is in a low-load or standby state at night, resulting in a lower baseline leakage current probability. Using the threshold from Example 1 would generate many false alarms at night. This example adjusts the leakage current probability threshold for adaptability: First probability threshold... Adjusted to 0.75, second probability threshold. Adjusted to 0.35. When When it is judged as a high risk of leakage; when When it is determined to be a medium risk of leakage; when It was determined to have a low risk of leakage.

[0145] Detailed rules for determining anomalies: The preset CPU load rate threshold is adjusted to 170% of the average value of inverters of the same model, and the preset network communication traffic threshold is adjusted to 160% of the average value of inverters of the same model. When the CPU load rate exceeds the threshold but the network communication traffic is normal, it is determined to be an equipment malfunction; when both the CPU load rate and the network communication traffic exceed the threshold, it is determined to be suspected electricity theft.

[0146] During the 6-month monitoring period, this embodiment detected a total of 12 high leakage risk events. Among them, inverter P078 had a leakage probability of 0.88, a CPU load rate of 91% (average of 38% for the same model), and normal network communication traffic, which was determined to be an abnormal equipment failure. On-site inspection revealed bulging of the DC bus capacitor. Inverter P142 had a leakage probability of 0.82, and both the CPU load rate and network communication traffic exceeded the threshold, which was determined to be suspected leakage. Another 9 events were verified by on-site investigation to be actual leakage caused by cable insulation aging, and 3 events were due to abnormal grounding of the photovoltaic module backsheet. The judgment results of all 12 events were verified on-site, confirming that the detection accuracy rate was 96.5%.

[0147] Step S9: Incremental learning and updating.

[0148] Whenever a new leakage current case is detected and confirmed on-site, the case data is added to the training set, and the model parameters are updated using incremental learning. ; Considering the significant seasonal variations in photovoltaic scenarios, with high summer irradiance and low winter irradiance having a substantial impact on the residual current baseline, the learning rate in this embodiment... An adaptive strategy is adopted, with an initial value set to 0.002. After each incremental learning iteration, the learning rate is reduced at a decay rate of 0.95. When 10 consecutive incremental learning iterations do not result in a significant performance improvement, the learning rate is reset to the initial value. The periodic retraining cycle is set to two weeks, which is shorter than in Example 1, to accommodate the residual current characteristic drift caused by seasonal variations.

[0149] Simultaneously, the model's prediction accuracy, recall, and F1 score are monitored online. A model update is triggered when the prediction accuracy drops by more than 5%. Nearly 12 historical versions of the model are retained for rollback purposes to support cross-seasonal rollback needs.

[0150] Step S10: Retrieve the Enhanced Generative (RAG) model to generate a repair plan.

[0151] See Figure 4 For malfunctioning inverters, the enhanced generative model is invoked to automatically generate a repair plan. The specific implementation method is as follows: The first step is to construct a maintenance knowledge vector library. This embodiment integrates photovoltaic inverter manufacturer manuals, grid connection technical regulations, cable insulation testing standards, a photovoltaic module fault case library, and high-voltage live-line working safety regulations, totaling approximately 8000 document fragments. Text vectorization uses the pre-trained language model BERT, and the vector representation is as follows: ,in .

[0152] The second step is query vector generation. The detected anomaly information is organized into query text, including photovoltaic-specific information such as inverter number, geographical region, leakage probability, anomaly type, DC component percentage, 150kHz frequency band energy percentage, CPU load rate deviation, and network communication traffic deviation. This text is then converted into query vectors using the same pre-trained language model. .

[0153] The third step is similarity retrieval. This involves calculating the cosine similarity between the query vector and the document vectors in the vector database. ; Step 4: Top-K sorting. Select the top K results with the highest similarity. Each document fragment serves as a relevant context document in this embodiment. Set it to 6.

[0154] Step 5: Large Model Generation. The relevant context documents and anomaly descriptions are assembled according to a preset prompt template and input into the large language model. The prompt template is: "Based on the following photovoltaic grid-connected scenario fault information: {anomaly description}, referencing the maintenance manual content: {document search}, please provide detailed maintenance steps, high-voltage safety protection measures, and suggestions according to the photovoltaic high-voltage live-line work procedures." The large language model outputs a structured maintenance plan containing maintenance steps, high-voltage safety protection measures, and suggestions. The large language model will also provide additional emphasis on safety precautions related to high-voltage live-line work to prevent personal injury to maintenance personnel due to procedural oversights.

[0155] Step 6: Solution Output and Feedback. The generated maintenance solution is pushed to the dedicated mobile terminal of the maintenance personnel in structured JSON format. For the faulty inverter P078, the maintenance steps recommended by the enhanced generation model include: applying for a shutdown permit, performing dual isolation on the DC and AC sides, waiting for the DC bus to discharge, checking the bulging of the DC bus capacitors, detecting the switching characteristics of the IGBT module, testing the insulation resistance, and performing a grid connection test after replacing the faulty component. For the inverter P142 suspected of leakage current, the recommended maintenance steps include: safe shutdown, disassembling and inspecting the metering circuit, verifying the current transformer, measuring the magnetic saturation characteristics of the current transformer, and detecting the cause of abnormal flow between the communication module and the main control chip. Compared with the traditional protection method based on residual current amplitude, this method significantly enhances the ability to identify 150kHz high-frequency components, improves the detection rate of latent leakage faults by approximately 32%, and increases the one-time accuracy of the maintenance solution from 68% in the traditional method to 89%.

[0156] In summary, this embodiment employs variational mode decomposition to reduce noise in the residual current signal, uses variance selection combined with principal component analysis for dimensionality reduction, employs multiple linear regression combined with logic functions to output leakage probability, and automatically generates maintenance plans through a retrieval-enhanced generative model. In an application scenario with 200 inverters in a photovoltaic grid-connected power plant, the detection accuracy reached 96.5%, and the ability to identify complex residual current components and the detection rate of latent leakage faults were significantly improved.

[0157] The embodiments of the present invention have at least the following technical effects: This invention employs variational mode decomposition to denoise residual current signals, effectively avoiding end-point effects and mode aliasing problems. It has good processing capabilities for DC components, pulsating components, and high-frequency components in complex residual current waveforms, significantly improving the robustness of signal denoising.

[0158] This invention employs a three-level feature processing mechanism that combines multidimensional feature extraction with variance selection and principal component analysis. This mechanism compresses feature dimensions while retaining most of the effective information, enabling the model to maintain high accuracy and stability even with a long prediction step size.

[0159] This invention uses multiple linear regression to output error prediction values ​​and converts them into leakage probability through a logic function, supporting high, medium and low leakage risk warnings, which is more precise and reasonable than the traditional binary judgment method.

[0160] This invention employs a joint determination mechanism based on CPU load rate and network communication traffic to precisely distinguish between equipment malfunctions and suspected power theft, helping maintenance personnel to take targeted measures.

[0161] This invention uses a retrieval-enhanced generative model combined with a pre-built maintenance knowledge vector base to automatically generate structured maintenance plans, which significantly reduces the reliance on the experience of maintenance personnel and improves maintenance efficiency and consistency.

[0162] This invention employs a model update mechanism that combines incremental learning with periodic retraining to achieve highly efficient closed-loop monitoring of "prediction before leakage and detection after leakage," enabling the method to continuously adapt to the dynamic evolution of leakage characteristics.

[0163] It is understood that the above embodiments are merely exemplary implementations used to illustrate the principles of the present invention, and the present invention is not limited thereto. For those skilled in the art, various modifications and improvements can be made without departing from the spirit and essence of the present invention, and these modifications and improvements are also considered to be within the scope of protection of the present invention.

Claims

1. A leakage current detection method based on PCA analysis and RAG, characterized in that, include: Collect the residual current signal and operating status parameters of the meter, reduce the noise of the residual current signal to obtain the noise-reduced residual current signal, and extract the feature parameter set containing time domain feature parameters and frequency domain feature parameters from the noise-reduced residual current signal. The feature parameter set is filtered to obtain a filtered feature parameter set, and principal component analysis is used to reduce the dimensionality of the filtered feature parameter set to obtain a comprehensive index. A regression model is constructed based on the mapping relationship between the comprehensive index and the metering error of the electricity meter. The regression model outputs an error prediction value. The error prediction value is transformed by a logic function to obtain the leakage probability. The abnormality type is determined based on the leakage probability and the operating status parameters. The anomaly type and its associated information are input into the retrieval enhancement generation model, which retrieves relevant context documents from a pre-built maintenance knowledge vector base and generates a maintenance plan based on the relevant context documents.

2. The leakage current detection method based on PCA analysis and RAG according to claim 1, characterized in that, After acquiring the residual current signal and before denoising the residual current signal, the process further includes performing data cleaning on the residual current signal. The data cleaning is performed as follows: The 3σ criterion and interquartile range method are used to detect outliers in the residual current signal. The 3σ criterion identifies data exceeding three times the mean standard deviation as outliers. The interquartile range method identifies data meeting the following conditions as outliers: or ; in, Indicating the residual current signal of the first One data point to be detected. The index of the data point. This represents the lower quartile of the residual current signal. This represents the upper quartile of the residual current signal. Indicates interquartile range and ; After deleting the detected outliers, the data is treated as missing data. The total number of missing data is obtained by combining this data with the original missing data in the residual current signal. The percentage of this total missing data relative to the total number of sampling points in a single acquisition cycle of the residual current signal is then calculated to obtain the missing data ratio. Based on this missing data ratio, a filling method is selected. When the missing proportion is less than the first threshold, linear interpolation is used; when the missing proportion is between the first and second thresholds, spline interpolation is used; and when the missing proportion is greater than the second threshold, mean imputation or moving average imputation based on historical data is used.

3. The leakage current detection method based on PCA analysis and RAG according to claim 1, characterized in that, The noise reduction of the residual current signal is performed as follows: The residual current signal is decomposed into variational mode decomposition. Given a modal function with finite bandwidth and a center frequency, the constrained variational problem constructed by the variational mode decomposition is: ; in, The index of the modal function and , This represents the total number of the modal functions. Represents a time variable. Indicates the first One modal function, Indicates the first The center frequency of each modal function Represents the Dirac distribution function. Represents the imaginary unit and , Represents pi (π). This represents the convolution operation. This represents the partial derivative operation with respect to the time variable. Denotes the square of the L2 norm. This represents the residual current signal; Introducing a secondary penalty factor and Lagrange multipliers The constrained variational problem is transformed into an unconstrained variational problem, where A preset positive real number greater than zero is used to control the trade-off between data fidelity and the constraints in the constrained variational problem. It is a time-varying Lagrange multiplier function used to maintain the strictness of the constraints; The alternating direction multiplier method is used to iteratively update each mode function, the center frequency, and the Lagrange multiplier; the decomposed... Selective reconstruction is performed on each of the mode functions to remove the noise-dominant mode functions and retain the mode functions corresponding to the useful signal components to obtain the noise-reduced residual current signal.

4. The leakage current detection method based on PCA analysis and RAG according to claim 1, characterized in that, The time-domain characteristic parameters include at least one of the following: mean, root mean square value, variance, peak value, peak factor, impulse factor, margin factor, waveform factor, skewness, kurtosis, rectified average value, energy, zero-crossing rate, and kurtosis index. The frequency domain characteristic parameters include at least one of the following: spectral mean, spectral standard deviation, spectral skewness, spectral kurtosis, dominant frequency, dominant frequency amplitude, spectral energy, harmonic component ratio, and the energy proportion of a preset high-frequency band.

5. The leakage current detection method based on PCA analysis and RAG according to claim 1, characterized in that, The method for filtering the feature parameter set is as follows: The variance of each feature in the feature parameter set is calculated using the variance selection method. Features with variances greater than a preset variance threshold are selected to form the filtered feature parameter set. The variance is calculated as follows: ; in, This represents a feature in the feature parameter set whose variance is to be calculated. Representation of features variance Represents the total number of samples. The sample number and , Indicates the first Each sample in features The value on, Representation of features In all The mean over a sample.

6. The leakage current detection method based on PCA analysis and RAG according to claim 1, characterized in that, The method for performing dimensionality reduction using principal component analysis on the filtered feature parameter set is as follows: The filtered feature parameter set is subjected to zero-mean and standardization to obtain a standardized matrix. The standardized matrix The number of rows is the total number of samples. The number of columns is the number of feature dimensions of the filtered feature parameter set. ; Calculate the covariance matrix of the normalized matrix: ; in, Let the covariance matrix be denoted as . OK A square array of columns, Represents the normalized matrix The transpose of the matrix, This represents the total number of samples; For the covariance matrix Performing eigenvalue decomposition yields eigenvalues ​​that satisfy the following equation: and the corresponding feature vector : ; in, The indices of the eigenvalues ​​and eigenvectors and , Indicates the first 1 eigenvalue, Indicates the first The eigenvectors corresponding to each eigenvalue; All The feature values ​​are sorted in descending order, and the top features whose cumulative variance contribution rate reaches the preset contribution rate threshold are selected. The eigenvectors corresponding to the eigenvalues ​​constitute the projection matrix. , Indicates the number of selected principal components and , No. The variance contribution rate of each principal component is calculated as follows: ; in, Indicates the first The variance contribution rate of each principal component This represents the number of feature dimensions. For summation index and ; The normalization matrix Project onto the projection matrix to obtain the comprehensive index: ; in, This represents the dimensionality-reduced sample matrix composed of the aforementioned comprehensive indices, which is... OK A matrix of columns.

7. The leakage current detection method based on PCA analysis and RAG according to claim 6, characterized in that, The regression model is a multiple linear regression model, and the expression of the regression model is: ; in, This represents the predicted error value. This indicates the number of principal components in the composite index. These respectively represent the 1st to the 1st of the comprehensive indicators. The values ​​of each principal component Represents the intercept term. They represent the 1st to the 1st. The regression coefficients corresponding to each principal component Represents the random error term; The regression coefficients were estimated using the least squares method. ; in, This represents the estimated vector of the regression coefficients. This represents the design matrix of the comprehensive index that includes all samples. Represents the design matrix The transpose of the matrix, Represents the design matrix The corresponding sample error observation vector; The leakage probability is obtained by converting the error prediction value through the logic function as follows: ; in, This represents the leakage probability. Let be a binary random variable representing whether a leakage event occurs and This indicates that a leakage has occurred. This represents the vector composed of the input comprehensive indicators. The base of the natural logarithm. Indicates the error prediction value and .

8. The leakage current detection method based on PCA analysis and RAG according to claim 1, characterized in that, The operating status parameters include the CPU load rate and network communication traffic of the electricity meter. The method for determining the anomaly type based on the leakage probability and the operating status parameters is as follows: When the leakage probability is greater than the first probability threshold, it is determined to be a high leakage risk; when the leakage probability is between the second probability threshold and the first probability threshold, it is determined to be a medium leakage risk; when the leakage probability is less than or equal to the second probability threshold, it is determined to be a low leakage risk, wherein the first probability threshold is greater than the second probability threshold. When the CPU load rate is higher than a preset load threshold and the network communication traffic is lower than a preset traffic threshold, the abnormality type is determined to be a device malfunction; when the CPU load rate is higher than the preset load threshold and the network communication traffic is higher than the preset traffic threshold, the abnormality type is determined to be suspected electricity theft.

9. The leakage current detection method based on PCA analysis and RAG according to claim 1, characterized in that, It also includes incremental update steps for the regression model and the logistic function: Whenever a new leakage current case is detected and confirmed, the data of the new leakage current case is added to the training set, and the model parameters are updated using incremental learning. The update expression for incremental learning is: ; in, This indicates the sequence number of the update count for the model parameters. Indicates the first Model parameters at the next update Indicates the first The updated model parameters. This represents a preset learning rate that is greater than zero and less than one. This represents the loss function of the regression model or the logistic function. The loss function represents the loss function with respect to the model parameters. gradient, This represents the input feature corresponding to the new leakage current case. This indicates the label corresponding to the new leakage current case; The prediction accuracy and recall of the regression model are monitored online, and the model is retrained when the decrease in prediction accuracy exceeds a preset performance threshold.

10. The leakage current detection method based on PCA analysis and RAG according to any one of claims 1 to 9, characterized in that, The execution method of the retrieval enhancement generation model generating the maintenance plan is as follows: The maintenance knowledge vector base is constructed by pre-processing text fragmentation and vectorization of maintenance manuals, fault case databases, and technical specifications, wherein the vector representation of text fragments is as follows: ; in, The index for the text segment, Indicates the first A text fragment, This represents the encoding function of the pre-trained language model. Indicates the first The vector obtained by encoding a text segment using the pre-trained language model's encoding function. This represents the dimension of the vector. express 3D real vector space; Convert the anomaly type and its associated information into a query vector. ,in This represents the vector obtained after the anomaly type and its associated information are encoded by the pre-trained language model encoding function. Calculate the cosine similarity between the query vector and each text fragment vector in the maintenance knowledge vector base: ; in, Represents the query vector With the first Text fragment vectors Cosine similarity between them Represents the query vector With the vector The inner product, Represents the query vector L2 norm, Represents the vector The L2 norm; Select the first with the highest similarity A text fragment serves as the relevant context document, wherein A preset positive integer representing the number of text fragments retrieved and greater than zero; The anomaly type, the associated information, and the relevant context documents are assembled according to a preset prompt word template and input into a large language model. The large language model then generates and outputs a structured maintenance plan that includes maintenance steps and suggestions.