Gas meter fault detection method, system and equipment based on multi-model fusion
By constructing a multi-XGBoost fusion fault detection model, which combines flow increment sequence and time coding information, the problems of low accuracy and efficiency in gas meter fault detection are solved, and high-precision fault detection is achieved.
Patent Information
- Application Number
- CN202211668389.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-23
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2042-12-23
AI Technical Summary
Existing gas meter fault detection methods suffer from high labor costs, low efficiency, and low accuracy and robustness of machine learning algorithms in complex and diverse scenarios.
A multi-model fusion-based fault detection method for gas meters is adopted. By preprocessing the gas flow data, a multi-XGBoost fusion fault detection model is constructed. The XGBoost layer and the fully connected layer are combined with the flow increment sequence, short-term flow information and time coding information for fault detection.
It improves the accuracy and robustness of gas meter fault detection, enabling timely capture of fault information and providing accurate inspection guidance.
Smart Images

Figure CN116049671B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of feature extraction and model building, and in particular to a method, system and device for detecting gas meter faults based on multi-model fusion. Background Technology
[0002] In recent years, the global energy structure has been rapidly transforming towards cleaner, lower-carbon, and more diversified energy sources. Coal and oil consumption will gradually decline, while natural gas will become a key area for medium- to long-term development. Over the past decade, natural gas consumption has grown rapidly, accounting for nearly one-third of the total increase in energy demand, exceeding that of any other fossil fuel. In today's era of big data and information technology, applying information technology to gas metering is an inevitable trend.
[0003] During the use of gas meters (represented by gas flow meters), over time, these meters often experience fault alarms such as pressure sensor failure, temperature sensor failure, and low wireless battery power. Traditional fault detection methods typically involve gas company personnel making regular on-site inspections, which is costly and inefficient. Existing technologies have also conducted research and applications on detecting gas meter faults based on data from commercial and industrial gas flow meters. Machine learning algorithms are a widely used fault detection technology in recent years; however, when applied to gas meter fault detection, they suffer from insufficient data samples and the complexity and diversity of real-world application scenarios, resulting in low accuracy and poor robustness in gas meter fault detection.
[0004] To address this issue, how to reconstruct machine learning algorithms to adapt to the complexity and diversity of real-world application scenarios, summarize patterns from the training set, extract features from the data, and provide real-time, accurate, and precise alarms for various meter malfunctions is a pressing technical problem that needs to be solved. Summary of the Invention
[0005] To overcome the shortcomings of the prior art, the present invention provides a gas meter fault detection method based on multi-model fusion, which can effectively solve the above problems.
[0006] The specific technical solution adopted in this invention is as follows:
[0007] In a first aspect, the present invention provides a gas meter fault detection method based on multi-model fusion, which includes the following steps:
[0008] S1. The standard condition cumulative flow sequence uploaded by the gas meters of all gas users is resampled by mean and the missing values are filled by linear interpolation. Then, the standard condition cumulative flow resampled sequence is subjected to first-order difference and normalized to obtain the standard condition flow increment sequence corresponding to each gas meter.
[0009] S2. Classify all gas users according to their gas usage characteristics, and construct a fault detection sample set containing positive and negative samples for each type of gas user based on the standard flow increment sequence. Each training sample in the fault detection sample set contains three flow increment subsequences extracted from the standard flow increment sequence before the detection time, short-term flow information, time coding information, and a label representing whether there is a meter fault at the detection time. The three flow increment subsequences have different sequence lengths. The short-term flow information consists of several flow increment values closest to the detection time in the standard flow increment sequence before the detection time. The time coding information includes a first coding information indicating whether the detection time is a weekday and a second coding information indicating whether the detection time is a holiday.
[0010] S3. For each type of gas user, train a multi-XGBoost fusion fault detection model using its corresponding fault detection sample set.
[0011] The multi-XGBoost fusion fault detection model comprises an input layer, an XGBoost layer, a fully connected layer, and an output layer. The input layer is used to input the traffic increment subsequence before the time to be detected. The XGBoost layer contains three XGBoost models, each of which takes the traffic increment subsequence as input and outputs a label representing whether a meter fault exists at the time to be detected. The lengths of the input traffic increment subsequences in the three XGBoost models in the XGBoost layer are different.
[0012] The input to the fully connected layer is the three labels, short-term traffic information, and time coding information output by the three XGBoost models, and the output is the final fault detection result.
[0013] S4. For the target gas user, obtain three flow increment subsequences, short-term flow information, and time coding information prior to the target time, and the length of the three flow increment subsequences is consistent with the sequence length in the training sample; according to the gas user category to which the target gas user belongs, input the obtained three flow increment subsequences, short-term flow information, and time coding information into the multi-XGBoost fusion fault detection model corresponding to the gas user category to predict whether a meter failure will occur in the future.
[0014] As a preferred embodiment of the first aspect above, in S1, when performing mean resampling, the standard condition cumulative flow sequence is divided into equal parts at fixed intervals, and the average value of each subsequence is taken as a resampled value; when performing linear interpolation on the missing values in the resampled sequence, the average value of the two available data on both sides of the missing value is taken to fill the missing value.
[0015] As a preferred embodiment of the first aspect above, S2 specifically includes the following sub-steps:
[0016] S21. Obtain the industry and gas-using equipment type of each gas user, and classify all gas users according to the two dimensions of industry and gas-using equipment type. Gas users with the same industry and the same gas-using equipment type are classified into the same gas user category.
[0017] S22. For each gas user category, obtain the standard flow increment sequence corresponding to all gas users in that category, and then iterate through these standard flow increment sequences to find outliers. For each outlier, construct a positive sample, and then construct a series of negative samples according to a preset positive-negative sample ratio. The positive and negative samples together form the fault detection sample set corresponding to the gas user category. The positive sample consists of three flow increment subsequences of different lengths before the outlier, short-term flow information, time coding information, and meter fault label. The negative sample consists of three flow increment subsequences of different lengths before the non-outlier, short-term flow information, time coding information, and meter fault-free label.
[0018] As a preferred embodiment of the first aspect above, S3 specifically includes the following sub-steps:
[0019] S31. For each type of gas user, obtain its corresponding fault detection sample set and initialize a multi-XGBoost fusion fault detection model.
[0020] S32. Input the fault detection sample set corresponding to each type of gas user in S31 into the multi-XGBoost fusion fault detection model to train the model;
[0021] The i-th training sample input to the multi-XGBoost fusion fault detection model is represented as [X i1 ,X i2 ,X i3 ,S i1 ,S i2 ,…,S iN Z i1 Z i2 ,Y i ], where X i1 ,X i2 ,X i3 S represents three flow increment subsequences of different lengths. i1 ,S i2 ,…,S iN Z represents the N traffic increment values closest to the detection time in the standard traffic increment sequence before the detection time corresponding to the i-th training sample. i1Z represents the first encoded information indicating whether the date corresponding to the detection time of the i-th training sample is a working day. i2 Y represents the second encoded information indicating whether the date of the detection time corresponding to the i-th training sample is a holiday. i The label indicates whether the time corresponding to the i-th training sample has a watch malfunction;
[0022] The three flow increment subsequences X in the i-th training sample i1 ,X i2 ,X i3 The input layer learns from three different XGBoost models in the XGBoost layer, with each input corresponding to a different input. Each of the three XGBoost models then outputs a prediction label indicating whether a meter malfunction will occur at the time to be detected, based on a single incremental traffic subsequence.
[0023] The predicted labels output by the three XGBoost models Compared with the short-term flow information S in the training samples i1 ,S i2 ,…,S iN and time-encoded information Z i1 Z i2 The samples are fed into a fully connected layer for learning, and the fully connected layer outputs a final fault detection result label representing whether a table fault will occur at the time corresponding to the i-th training sample.
[0024] S33, Label Y with truth value i With predictive labels The loss function value is calculated, and the network parameters of the three XGBoost models and the fully connected layer in the multi-XGBoost fusion fault detection model are optimized. The process is iterated until the iteration termination condition is met, thus completing the model training for each type of gas user.
[0025] As a preferred embodiment of the first aspect above, the mean resampling is performed at a fixed interval of 1 hour.
[0026] As a preferred embodiment of the first aspect above, in the XGBoost layer, the lengths of the three traffic increment subsequences input in the three XGBoost models are 1 day, 1 week and 2 weeks, or 1 day, 1 week and 1 month, or 1 day, 1 week and 1 year, preferably 1 day, 1 week and 2 weeks.
[0027] As a preferred embodiment of the first aspect above, the ratio of positive samples to negative samples in the fault detection sample set is 1:8 to 10.
[0028] As a preferred embodiment of the first aspect above, the number N of the short-term traffic information is 4 to 6, preferably 5.
[0029] Secondly, the present invention provides a gas meter fault detection system based on multi-model fusion, comprising:
[0030] The data acquisition module is used to resample the standard condition cumulative flow sequence uploaded by the gas meters of all gas users, fill the missing values by linear interpolation, and then perform first-order difference and normalization on the standard condition cumulative flow resampled sequence to obtain the standard condition flow increment sequence corresponding to each gas meter.
[0031] The sample construction module is used to classify all gas users according to their gas usage characteristics, and to construct a fault detection sample set containing positive and negative samples for each type of gas user based on the standard flow increment sequence. Each training sample in the fault detection sample set contains three flow increment subsequences extracted from the standard flow increment sequence before the detection time, short-term flow information, time coding information, and a label representing whether there is a meter fault at the detection time. The three flow increment subsequences have different sequence lengths. The short-term flow information consists of several flow increment values closest to the detection time in the standard flow increment sequence before the detection time. The time coding information includes a first coding information indicating whether the detection time is a weekday and a second coding information indicating whether the detection time is a holiday.
[0032] The model training module is used to train a multi-XGBoost fusion fault detection model for each type of gas user using its corresponding fault detection sample set.
[0033] The multi-XGBoost fusion fault detection model comprises an input layer, an XGBoost layer, a fully connected layer, and an output layer. The input layer is used to input the traffic increment subsequence before the time to be detected. The XGBoost layer contains three XGBoost models, each of which takes the traffic increment subsequence as input and outputs a label representing whether a meter fault exists at the time to be detected. The lengths of the input traffic increment subsequences in the three XGBoost models in the XGBoost layer are different.
[0034] The input to the fully connected layer is the three labels, short-term traffic information, and time coding information output by the three XGBoost models, and the output is the final fault detection result.
[0035] The meter fault prediction module is used to acquire three flow increment subsequences, short-term flow information, and time-coding information for a target gas user before a target time, with the length of the three flow increment subsequences being consistent with the sequence length in the training samples. Based on the gas user category to which the target gas user belongs, the acquired three flow increment subsequences, short-term flow information, and time-coding information are input into the multi-XGBoost fusion fault detection model corresponding to that gas user category to predict whether a meter fault will occur in the future.
[0036] In a second aspect, the present invention provides a computer electronic device, which includes a memory and a processor;
[0037] The memory is used to store computer programs;
[0038] The processor is configured to, when executing the computer program, implement the gas meter fault detection method based on multi-model fusion as described in any of the solutions in the first aspect above.
[0039] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0040] 1) This invention is based on gas flow usage data, extracts gas flow usage features through machine learning methods, and completes gas meter fault detection based on these features. It has the characteristics of high accuracy and strong scalability, and can capture fault information in a timely manner, providing guidance and basis for the inspection of gas meter faults.
[0041] 2) The multi-XGBoost fusion fault detection model of the present invention integrates three types of information that can be used to sense flow abnormalities caused by meter failures. Long-term sequence information enables the model to sense the long-term gas consumption characteristics of gas users, while short-term sequence information can reflect the abnormal fluctuations in gas consumption before the meter failure. Time coding information enables the model to distinguish the changes in gas consumption characteristics between weekdays and holidays, thereby improving the model's accuracy and robustness in identifying faults of gas flow meters and other meters. Attached Figure Description
[0042] Figure 1 This is a flowchart of the method of the present invention;
[0043] Figure 2 This is a schematic diagram illustrating the fusion of multiple XGBoost models trained for fault detection according to the present invention.
[0044] Figure 3 This is a comparison graph of the experimental results of the present invention and the control method;
[0045] Figure 4 This is a comparison chart of experimental results across different time dimensions for this invention. Detailed Implementation
[0046] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Many specific details are set forth in the following description to provide a thorough understanding of the present invention. However, the present invention can be practiced in many other ways different from those described herein, and those skilled in the art can make similar modifications without departing from the spirit of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below. Technical features in the various embodiments of the present invention can be combined accordingly without mutual conflict.
[0047] In the description of this invention, it should be understood that the terms "first" and "second" are used only for descriptive purposes and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature.
[0048] like Figure 1 As shown, this invention provides a gas meter fault detection method based on multi-model fusion. The method first preprocesses the raw data uploaded by the gas flow meter, filtering out invalid data. It then performs resampling, interpolation, differencing, and normalization operations on the standard cumulative flow data uploaded by the gas flow meter, thereby constructing a fault detection sample set. Next, a hierarchical multi-XGBoost fusion fault detection model is constructed. N different XGBoost models are established in the first layer and fused in the second layer. The classification of the first-layer XGBoost model is used as the input to the fully connected layer, and short-term flow information and time-coded information are concatenated. Finally, the fault detection sample set is used for training and testing, outputting the gas meter fault detection results. This invention, based on gas flow usage data, extracts gas flow usage features through machine learning methods and completes gas meter fault detection based on these features. It features high accuracy and strong scalability, and can promptly capture fault information, providing guidance to relevant personnel.
[0049] In a preferred embodiment of the present invention, the above-mentioned gas meter fault detection method based on multi-model fusion specifically includes steps S1 to S4, and the specific implementation of each step is described in detail below.
[0050] S1. The standard condition cumulative flow sequence uploaded by the gas meters of all gas users is resampled by mean and the missing values are filled by linear interpolation. Then, the standard condition cumulative flow resampled sequence is subjected to first-order difference and normalized to obtain the standard condition flow increment sequence corresponding to each gas meter.
[0051] In embodiments of the present invention, step S1 specifically includes the following sub-steps:
[0052] S11. Obtain the original standard condition cumulative flow sequence collected by the gas flow meter for each gas user, and resample it by mean to generate a resampled flow sequence with a fixed interval Δt. m is the length of the sequence after resampling; during mean resampling, resampling points in the original sequence that have no flow value are set to null values.
[0053] S12. The null points in the resampled flow sequence Q obtained in S11 are filled by linear interpolation. The mean of the flow values on both sides of the null point is used to fill the null point, thus obtaining the resampled flow interpolation sequence Q′.
[0054] S13. Perform a first-order difference on the resampled interpolation sequence Q′ obtained in S12 to obtain the standard condition flow rate increment sequence D=(d1,d2,…,d m ), where d j Let j = 1, 2, ..., m, be the cumulative increase in standard flow rate of the flow meter during a resampling time interval.
[0055] S14. Normalize each standard condition flow increment sequence D after the first-order difference is completed. The normalization method can be max-min normalization to the range [0,1].
[0056] The standard condition cumulative flow sequence uploaded by the gas flow meter may contain a large amount of missing data due to various reasons. Therefore, resampling can improve the quality of the sequence data. In this embodiment, the mean resampling method is used, which averages all the original flow values within the time interval Δt to obtain the resampled flow value. Specifically, the generated resampled flow sequence... Among them, the resampled flow value n′ is between t k and t k+1 The number of original standard condition cumulative flow values within a time period, if t k and t k+1 If there is no traffic value within the time interval, then set... It is an empty value.
[0057] The fixed interval Δt for resampling can be optimized and adjusted according to actual conditions. In this embodiment, Δt is 1 hour. Therefore, the sequence of each day is resampled at an interval of one hour. The resampled value is recorded as the average of all flow values within one hour. The daily sequence of a day contains 24 resampled flow values.
[0058] It should be noted that the standard condition cumulative flow sequence uploaded by the gas flow meters of all gas users used in S1 to construct the sequence dataset can be collected online or offline historical data, and there is no restriction on this.
[0059] S2. Classify all gas users according to their gas usage characteristics, and construct a fault detection sample set containing positive and negative samples for each type of gas user based on the standard flow increment sequence. Each training sample in the fault detection sample set contains three flow increment subsequences extracted from the standard flow increment sequence before the detection time, short-term flow information, time coding information, and a label representing whether there is a meter fault at the detection time. The three flow increment subsequences have different sequence lengths. The short-term flow information consists of several flow increment values closest to the detection time in the standard flow increment sequence before the detection time. The time coding information includes a first coding information indicating whether the detection time is a weekday and a second coding information indicating whether the detection time is a holiday.
[0060] In embodiments of the present invention, step S2 specifically includes the following sub-steps:
[0061] S21. Obtain the industry and gas-using equipment type of each gas user, and classify all gas users according to the two dimensions of industry and gas-using equipment type. Gas users with the same industry and the same gas-using equipment type are classified into the same gas user category.
[0062] In this invention, through analysis of gas data, it was found that different industries and different gas-using devices within the same industry have different gas consumption characteristics. Therefore, in this embodiment, all gas users are classified according to two combined dimensions: industry and type of gas-using device, so as to build subsequent fault detection models for each category and improve the fault detection accuracy of each type of gas user.
[0063] S22. For each gas user category, obtain the standard flow increment sequence corresponding to all gas users in that category, and then iterate through these standard flow increment sequences to find outliers. For each outlier, construct a positive sample, and then construct a series of negative samples according to a preset positive-negative sample ratio. The positive and negative samples together form the fault detection sample set corresponding to the gas user category. The positive sample consists of three flow increment subsequences of different lengths before the outlier, short-term flow information, time coding information, and meter fault label. The negative sample consists of three flow increment subsequences of different lengths before the non-outlier, short-term flow information, time coding information, and meter fault-free label.
[0064] It should be noted that outliers in the standard condition flow increment sequence can be automatically identified using statistical methods or manually, and there are no restrictions on this. m Assume the k-th point d k If it is an outlier, then it can be based on dk Construct three flow increment subsequences X of different lengths from a positive sample. i1 X i2 X i3 Assume X i1 X i2 X i3 If the sequence lengths are h1, h2, and h3 respectively, then The short-term flow information S in this positive sample i1 S i2 S iN That is, d k-N d k-N+1 , ..., d k-1 The time-coded information is point d. k Is the date a workday? (First information code z) i1 ∈{0,1}, point d k The second information code Z indicates whether the date falls on a public holiday. i2 ∈{0, 1}. For Z i1 Point d k The date in question is coded as 1 for weekdays and 0 for non-weekdays; for z i2 Point d k The date is coded as 1 for holidays and 0 for non-holidays. Holidays can be determined based on the statutory holiday schedule of the gas user's region. The label Y in this positive sample... i Set it as a meter fault label, i.e., set it to 1.
[0065] Since the number of outliers in normal gas data is far less than the number of normal data points, to ensure the reliability of subsequent model training, the ratio of positive to negative samples in the fault detection sample set can be set to 1:8 to 10. Therefore, after constructing positive samples based on all outliers, corresponding negative samples can be configured according to this ratio. Each negative sample can be generated by randomly selecting a non-outlier from the standard condition flow increment sequence D, and then selecting three flow increment subsequences X of different lengths in the same manner as for the positive samples. i1 X i2 X i3 And extract short-term traffic information S i1 S i2 S iN Determine the time encoding information Z i1 and Z i2 The label Y in the negative sample i Set the meter to have no fault label, i.e., set it to 0.
[0066] S3. For each type of gas user, train a multi-XGBoost fusion fault detection model using its corresponding fault detection sample set.
[0067] like Figure 2 The diagram shows the network structure of this multi-XGBoost fusion fault detection model, which includes an input layer, an XGBoost layer, a fully connected layer, and an output layer. The input layer takes the traffic increment subsequence prior to the time to be detected as input. The XGBoost layer contains three XGBoost models, each taking the traffic increment subsequence as input and outputting a label indicating whether a meter fault exists at the time to be detected. It is important to note that the traffic increment subsequences input to the three XGBoost models in the XGBoost layer have different lengths. This allows for the extraction of abnormal precursor information caused by meter faults from sequences of different lengths, which are then fused into the final fault detection result. The fully connected layer takes as input the three labels output by the three XGBoost models, short-term traffic information, and time-coded information, and outputs the final fault detection result.
[0068] In an embodiment of the present invention, step S3 specifically includes the following sub-steps:
[0069] S31. For each type of gas user, obtain its corresponding fault detection sample set and initialize a multi-XGBoost fusion fault detection model.
[0070] S32. Input the fault detection sample set corresponding to each type of gas user in S31 into the multi-XGBoost fusion fault detection model to train the model.
[0071] For the multi-XGBoost fusion fault detection model, the specific network processing flow is as follows:
[0072] The i-th training sample input to the multi-XGBoost fusion fault detection model is represented as [X i1 ,X i2 ,X i3 ,S i1 ,S i2 ,…,S iN Z i1 Z i2 ,Y i ], where X i1 ,X i2 ,X i3 S represents three flow increment subsequences of different lengths. i1 ,S i2 ,…,S iNZ represents the N traffic increment values closest to the detection time in the standard traffic increment sequence before the detection time corresponding to the i-th training sample. i1 Z represents the first encoded information indicating whether the date corresponding to the detection time of the i-th training sample is a working day. i2 Y represents the second encoded information indicating whether the date of the detection time corresponding to the i-th training sample is a holiday. i This indicates whether the time corresponding to the i-th training sample has a label indicating whether there is a watch malfunction.
[0073] The three flow increment subsequences X in the i-th training sample i1 ,X i2 ,X i3 The input layer learns from three different XGBoost models in the XGBoost layer, with each input corresponding to a different input. Each of the three XGBoost models then outputs a prediction label indicating whether a meter malfunction will occur at the time to be detected, based on a single incremental traffic subsequence.
[0074] The predicted labels output by the three XGBoost models Compared with the short-term flow information S in the training samples i1 ,S i2 ,…,S iN and time-encoded information Z i1 Z i2 The samples are fed into a fully connected layer for learning, and the fully connected layer outputs a final fault detection result label representing whether a table fault will occur at the time corresponding to the i-th training sample.
[0075] S33, Label Y with truth value i With predictive labels The loss function value is calculated, and the network parameters of the three XGBoost models and the fully connected layer in the multi-XGBoost fusion fault detection model are optimized. The process is iterated until the iteration termination condition is met, thus completing the model training for each type of gas user.
[0076] It should be noted that XGBoost is a supervised model, and its specific principles and implementation methods belong to existing technologies. For ease of understanding, the general principles and model construction process of this model are briefly introduced below.
[0077] XGBoost is a machine learning algorithm based on gradient boosting techniques, consisting of multiple Classification and Regression Trees (CART). Training a network model based on the fusion of multiple XGBoost trees includes the following sub-steps:
[0078] 1) For a given dataset L with n samples and m features train ={(X i ,Y i )}(|D|=n,X i ∈R m ,Y i ∈R), where X i Y is a sample vector with m-dimensional features. i To be with X i The corresponding actual classification is given by R, which represents the dataset. The classification is predicted using an XGBoost model ensembled from K CART trees, as shown in the following process:
[0079]
[0080] in, For the predicted classification of the actual classification, Γ={f k (X i )=ω q (X i )}(q:R m →T,ω∈R T ) is the function space of CART, f k (·) represents the k-th tree, q represents the tree structure, T represents the number of leaf nodes, and each f k Each corresponds to an independent tree structure q and leaf weight ω, k∈[1,K];
[0081] 2) To effectively combine K trees to form XGBoost, the regularization function L must be minimized. The process is as follows:
[0082]
[0083] in, For the loss function term, This is a regularization term. ‖ω‖ 2 This represents the sum of squares of the leaf weights. The loss function term l represents the predicted value. and actual value Y i The squared error. In the regularization term Ω, γ and λ are coefficients; the former constrains the number of leaf nodes T, and the latter constrains the leaf weights ω, which helps to avoid overfitting.
[0084] 3) Building an XGBoost model involves iteratively adding trees. Let i be the predicted value of the i-th sample in the t-th iteration. The objective function is minimized by iteratively adding trees, and the process is expressed as follows:
[0085]
[0086] 4) Apply a second-order Taylor expansion to the objective function. The expansion result is expressed as:
[0087]
[0088] in These are the first and second derivatives of the loss function term;
[0089] 5) When adding the t-th tree, the previous t-1 trees have already been combined. Since this is a constant term, we ignore it to obtain the simplified form of the objective function at step t. The process is expressed as follows:
[0090]
[0091] 6) Define L j ={i|q(X) i Let )=j} be the sample set of leaf node j. Expand the regularization term Ω as follows:
[0092]
[0093] 7) For a certain tree structure q(X), let the weight ω of the leaf node j in the above formula be ω j The optimal weight ω can be obtained by taking the partial derivative. j * The process is represented as follows:
[0094]
[0095] 8) For a given tree structure q(X), the optimal objective function value is The smaller the value of this function, the better the tree structure. At this point, the XGBoost model is complete.
[0096] Training the XGBoost model is also a current technology. For each type of gas user, a corresponding fault detection sample set can be obtained and divided into a training set and a test set for training the entire multi-XGBoost fusion fault detection model. Generally, 70% of the data in the fault detection sample set can be divided into a training set L. train The remaining 30% of the data is the test set L. test .
[0097] In this invention, the aforementioned multi-XGBoost fusion fault detection model integrates three types of information that can be used to detect flow anomalies caused by meter malfunctions. The first type of information is long-term sequence information, namely three flow increment subsequences X of different lengths. i1 ,X i2 ,X i3 The second type of information is short-term sequence information, namely the N flow increment values S closest to the time to be detected. i1 ,S i2 ,…,S iNThe third type of information is the code Z indicating whether the date of the time to be detected is a weekday or a holiday. i1 and Z i2 Long-term sequence information allows the model to perceive the long-term gas consumption characteristics of gas users, while short-term sequence information can reflect abnormal fluctuations in gas consumption before meter failure. Time-coded information enables the model to distinguish the changes in gas consumption characteristics between weekdays and holidays, avoiding identification errors.
[0098] Therefore, the aforementioned multi-XGBoost fusion fault detection model requires setting several parameters, among which the key parameters are the lengths h1, h2, and h3 of the three traffic increment subsequences input to the three XGBoost models, and the number N of traffic increment values in the short-term traffic information. This relates to the distribution of long-term and short-term sequence information that the model can perceive. In this invention, after optimization, the lengths of the three traffic increment subsequences input to the three XGBoost models can be set to 1 day, 1 week, and 2 weeks, or 1 day, 1 week, and 1 month, or 1 day, 1 week, and 1 year, preferably 1 day, 1 week, and 2 weeks. In the short-term traffic information, the number N of traffic increment values is 4 to 6, preferably 5.
[0099] S4. For the target gas user, obtain three flow increment subsequences, short-term flow information, and time coding information prior to the target time, and the length of the three flow increment subsequences is consistent with the sequence length in the training sample; according to the gas user category to which the target gas user belongs, input the obtained three flow increment subsequences, short-term flow information, and time coding information into the multi-XGBoost fusion fault detection model corresponding to the gas user category to predict whether a meter failure will occur in the future.
[0100] It should be noted that the target gas user mentioned in step S4 of this invention is a specific user who needs to undergo gas meter fault detection, and can be specified according to actual detection needs. Furthermore, the target time for anomaly detection can also be specified according to actual detection needs; it can be the current real-time moment or a non-current moment, depending on the fault detection time interval.
[0101] It should be noted that the above-mentioned three flow increment subsequences, short-term flow information and time-coded information for the target gas user before the target time are constructed in the same way as the aforementioned training samples. The only difference is that the sequence data is changed to the current sequence of the target gas user.
[0102] It should be noted that the gas meter in this invention is a gas meter used to record the cumulative flow under standard conditions, and can be a gas flow meter or its equivalent device.
[0103] Furthermore, based on the same inventive concept as the gas meter fault detection method based on multi-model fusion provided in the above embodiments, another preferred embodiment of the present invention provides a gas meter fault detection system based on multi-model fusion, which includes the following functional modules:
[0104] The data acquisition module is used to resample the standard condition cumulative flow sequence uploaded by the gas meters of all gas users, fill the missing values by linear interpolation, and then perform first-order difference and normalization on the standard condition cumulative flow resampled sequence to obtain the standard condition flow increment sequence corresponding to each gas meter.
[0105] The sample construction module is used to classify all gas users according to their gas usage characteristics, and to construct a fault detection sample set containing positive and negative samples for each type of gas user based on the standard flow increment sequence. Each training sample in the fault detection sample set contains three flow increment subsequences extracted from the standard flow increment sequence before the detection time, short-term flow information, time coding information, and a label representing whether there is a meter fault at the detection time. The three flow increment subsequences have different sequence lengths. The short-term flow information consists of several flow increment values closest to the detection time in the standard flow increment sequence before the detection time. The time coding information includes a first coding information indicating whether the detection time is a weekday and a second coding information indicating whether the detection time is a holiday.
[0106] The model training module is used to train a multi-XGBoost fusion fault detection model for each type of gas user using its corresponding fault detection sample set.
[0107] The multi-XGBoost fusion fault detection model comprises an input layer, an XGBoost layer, a fully connected layer, and an output layer. The input layer is used to input the traffic increment subsequence before the time to be detected. The XGBoost layer contains three XGBoost models, each of which takes the traffic increment subsequence as input and outputs a label representing whether a meter fault exists at the time to be detected. The lengths of the input traffic increment subsequences in the three XGBoost models in the XGBoost layer are different.
[0108] The input to the fully connected layer is the three labels, short-term traffic information, and time coding information output by the three XGBoost models, and the output is the final fault detection result.
[0109] The meter fault prediction module is used to acquire three flow increment subsequences, short-term flow information, and time-coding information for a target gas user before a target time, with the length of the three flow increment subsequences being consistent with the sequence length in the training samples. Based on the gas user category to which the target gas user belongs, the acquired three flow increment subsequences, short-term flow information, and time-coding information are input into the multi-XGBoost fusion fault detection model corresponding to that gas user category to predict whether a meter fault will occur in the future.
[0110] Since the principle of the gas flow anomaly detection method based on machine learning and dynamic threshold is similar to the gas meter fault detection system based on multi-model fusion in the above embodiment of the present invention, the specific implementation forms of each module of the system in this embodiment can also be referred to the specific implementation forms of the method shown in S1 to S4 above, and the repeated parts will not be described again.
[0111] It should also be noted that in the systems provided in the above embodiments, each module is executed sequentially as a program module, thus essentially performing a data processing flow. Furthermore, those skilled in the art will understand that, for the sake of convenience and brevity, the specific working process of the system described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here. In the embodiments provided in this application, the division of steps or modules in the methods and systems is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple modules or steps may be combined or integrated together, and a module or step may also be split.
[0112] Similarly, based on the same inventive concept, another preferred embodiment of the present invention also provides a computer electronic device corresponding to the gas meter fault detection method based on multi-model fusion provided in the above embodiments, which includes a memory and a processor;
[0113] The memory is used to store computer programs;
[0114] The processor is configured to implement the gas meter fault detection method based on multi-model fusion as described in the foregoing embodiments when executing the computer program.
[0115] It is understood that the aforementioned memory can be random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Furthermore, the storage medium can also be any medium capable of storing program code, such as a USB flash drive, external hard drive, magnetic disk, or optical disk.
[0116] It is understood that the processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0117] The present invention will further illustrate the detailed implementation process of the gas meter fault detection method and system based on multi-model fusion in the above embodiments through a specific example, so as to facilitate understanding of the essence of the present invention.
[0118] Example
[0119] The steps in this embodiment are the same as those in the specific implementation method, and will not be repeated here. The following section demonstrates some of the implementation process and results:
[0120] The raw data used in this embodiment is real gas flow usage data provided by Zhejiang Cangnan Instrument Group Co., Ltd. A total of 22,165 flow records were selected from all meters containing fault tags, representing 40 industry categories and 1,082 gas flow meters. The time span of the data records for each gas flow meter is 2-3 years. The data was processed according to the method of this invention and input into the model for training. Finally, the trained model was used for meter fault detection. Some parameter settings in this embodiment are as follows: the time interval Δt for mean resampling is 1 hour; the ratio of positive to negative samples in the fault detection sample set is 1:10. In the XGBoost model, parameter m is 1, representing the standard condition flow increment sequence; K is 100, representing the number of decision trees; γ is 0.1; λ is 2; ω... j The minimum leaf node weight is set to 3. In the fully connected layer, there are 10 input layer nodes, 5 hidden layer nodes, and 1 output layer node, which is used to output the final fault detection result.
[0121] In this embodiment, the method of the present invention (denoted as multi-XGBoost fusion) is compared with several traditional classification methods. The prediction methods used as comparisons are: (1) OCSVM (OneClass SVM): Support Vector Machine is a type of generalized linear classifier that performs binary classification of data; (2) Decision Tree: Decision Tree is a type of multi-class model that uses a tree model to make decisions. The experiment uses the precision, recall and F1 score of the detection results as the detection evaluation indicators.
[0122] Experimental results are as follows Figure 3 As shown, taking the detection results of instrument 1 as an example, the method of the present invention outperforms OCSVM and Decision Tree by 14.3% and 11.4% respectively in terms of F1 value.
[0123] To demonstrate the impact of fusing input sequences of different time lengths in the multi-XGBoost model on fault detection results, the experiment compared the method of this invention (divided into three groups based on the different lengths of the three input traffic increment subsequences in the three XGBoost models: 1D+1W+2W represents three sequences with lengths of 1 day, 1 week, and 2 weeks; 1D+1W+1M represents three sequences with lengths of 1 day, 1 week, and 1 month; and 1D+1W+1Y represents three sequences with lengths of 1 day, 1 week, and 1 year) with a single XGBoost model (the input traffic increment subsequence contains only one, i.e., a sequence with a length of 1 day, with the rest of the approach consistent with multi-XGBoost fusion) and multi-XGBoost fusion models with different time dimensions. The experimental results are as follows: Figure 4 As shown in the results, the multi-XGBoost fusion model outperforms the single XGBoost model in terms of F1 score. Furthermore, the optimal time dimension selection for the multi-XGBoost fusion model is 1D+1W+2W, achieving an F1 score of 0.7576. This demonstrates the effectiveness of the gas meter fault detection method based on multi-model fusion proposed in this invention.
[0124] The embodiments described above are merely preferred embodiments of the present invention and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained through equivalent substitution or transformation fall within the protection scope of the present invention.
Claims
1. A gas meter fault detection method based on multi-model fusion, characterized in that, Includes the following steps: S1. The standard condition cumulative flow sequence uploaded by the gas meters of all gas users is resampled by mean and the missing values are filled by linear interpolation. Then, the standard condition cumulative flow resampled sequence is subjected to first-order difference and normalized to obtain the standard condition flow increment sequence corresponding to each gas meter. S2. Classify all gas users according to their gas usage characteristics, and construct a fault detection sample set containing positive and negative samples for each type of gas user based on the standard flow increment sequence. Each training sample in the fault detection sample set contains three flow increment subsequences extracted from the standard flow increment sequence before the detection time, short-term flow information, time coding information, and a label representing whether there is a meter fault at the detection time. The three flow increment subsequences have different sequence lengths. The short-term flow information consists of several flow increment values closest to the detection time in the standard flow increment sequence before the detection time. The time coding information includes a first coding information indicating whether the detection time is a weekday and a second coding information indicating whether the detection time is a holiday. S3. For each type of gas user, train a multi-XGBoost fusion fault detection model using its corresponding fault detection sample set. The multi-XGBoost fusion fault detection model comprises an input layer, an XGBoost layer, a fully connected layer, and an output layer. The input layer is used to input the traffic increment subsequence before the time to be detected. The XGBoost layer contains three XGBoost models, each of which takes the traffic increment subsequence as input and outputs a label representing whether a meter fault exists at the time to be detected. The lengths of the input traffic increment subsequences in the three XGBoost models in the XGBoost layer are different. The input to the fully connected layer is the three labels, short-term traffic information, and time coding information output by the three XGBoost models, and the output is the final fault detection result. S4. For the target gas user, obtain three flow increment subsequences, short-term flow information, and time coding information prior to the target time, and the length of the three flow increment subsequences is consistent with the sequence length in the training sample; according to the gas user category to which the target gas user belongs, input the obtained three flow increment subsequences, short-term flow information, and time coding information into the multi-XGBoost fusion fault detection model corresponding to the gas user category to predict whether a meter failure will occur in the future.
2. The gas meter fault detection method based on multi-model fusion as described in claim 1, characterized in that, In S1, when performing mean resampling, the standard condition cumulative flow sequence is divided into equal parts at fixed intervals, and the average value of each subsequence is taken as a resampled value; when performing linear interpolation on the missing values in the resampled sequence, the average value of the two available data on both sides of the missing value is taken to fill the missing value.
3. The gas meter fault detection method based on multi-model fusion as described in claim 1, characterized in that, S2 specifically includes the following sub-steps: S21. Obtain the industry and gas-using equipment type of each gas user, and classify all gas users according to the two dimensions of industry and gas-using equipment type. Gas users with the same industry and the same gas-using equipment type are classified into the same gas user category. S22. For each gas user category, obtain the standard flow increment sequence corresponding to all gas users in that category, then iterate through these standard flow increment sequences to find outliers. For each outlier, construct a positive sample, and then construct a series of negative samples according to a preset positive-negative sample ratio. The positive and negative samples together form the fault detection sample set corresponding to that gas user category. The positive sample consists of three flow increment subsequences of different lengths before the outlier, short-term flow information, time coding information, and meter fault label. The negative sample consists of three flow increment subsequences of different lengths before the non-outlier, short-term flow information, time coding information, and meter fault-free label.
4. The gas meter fault detection method based on multi-model fusion as described in claim 1, characterized in that, S3 specifically includes the following sub-steps: S31. For each type of gas user, obtain its corresponding fault detection sample set and initialize a multi-XGBoost fusion fault detection model. S32. Input the fault detection sample set corresponding to each type of gas user in S31 into the multi-XGBoost fusion fault detection model to train the model; The i-th training sample input to the multi-XGBoost fusion fault detection model is represented as [X i1 ,X i2 ,X i3 ,S i1 ,S i2 ,…,S iN Z i1 Z i2 ,Y i ], where X i1 ,X i2 ,X i3 S represents three flow increment subsequences of different lengths. i1 ,S i2 ,…,S iN Z represents the N traffic increment values closest to the detection time in the standard traffic increment sequence before the detection time corresponding to the i-th training sample. i1 Z represents the first encoded information indicating whether the date corresponding to the detection time of the i-th training sample is a working day. i2 Y represents the second encoded information indicating whether the date of the detection time corresponding to the i-th training sample is a holiday. i The label indicates whether the time corresponding to the i-th training sample has a watch malfunction; The three flow increment subsequences X in the i-th training sample i1 ,X i2 ,X i3 The input layer learns from three different XGBoost models in the XGBoost layer, with each input corresponding to a different input. Each of the three XGBoost models then outputs a prediction label indicating whether a meter malfunction will occur at the time to be detected, based on a single incremental traffic subsequence. The predicted labels output by the three XGBoost models Short-term flow information S in the training samples i1 ,S i2 ,…,S iN and time-encoded information Z i1 Z i2 The samples are fed into a fully connected layer for learning, and the fully connected layer outputs a final fault detection result label representing whether a table fault will occur at the time corresponding to the i-th training sample. S33, Label Y with truth value i With predictive labels The loss function value is calculated, and the network parameters of the three XGBoost models and the fully connected layer in the multi-XGBoost fusion fault detection model are optimized. The process is iterated until the iteration termination condition is met, thus completing the model training for each type of gas user.
5. The gas meter fault detection method based on multi-model fusion as described in claim 2, characterized in that, The mean resampling is performed at a fixed interval of 1 hour.
6. The gas meter fault detection method based on multi-model fusion as described in claim 1, characterized in that, In the XGBoost layer, the lengths of the three incremental subsequences of traffic input in the three XGBoost models are 1 day, 1 week and 2 weeks, or 1 day, 1 week and 1 month, or 1 day, 1 week and 1 year, respectively.
7. The gas meter fault detection method based on multi-model fusion as described in claim 1, characterized in that, In the XGBoost layer, the lengths of the three incremental traffic subsequences input to the three XGBoost models are 1 day, 1 week, and 2 weeks.
8. The gas meter fault detection method based on multi-model fusion as described in claim 1, characterized in that, In the fault detection sample set, the ratio of positive samples to negative samples is 1:(8-10).
9. The gas meter fault detection method based on multi-model fusion as described in claim 4, characterized in that, In the short-term traffic information, the number N of traffic increment values is 4 to 6.
10. The gas meter fault detection method based on multi-model fusion as described in claim 4, characterized in that, In the short-term traffic information, the number N of traffic increment values is 5.
11. A gas meter fault detection system based on multi-model fusion, characterized in that, include: The data acquisition module is used to resample the standard condition cumulative flow sequence uploaded by the gas meters of all gas users, fill the missing values by linear interpolation, and then perform first-order difference and normalization on the standard condition cumulative flow resampled sequence to obtain the standard condition flow increment sequence corresponding to each gas meter. The sample construction module is used to classify all gas users according to their gas usage characteristics, and to construct a fault detection sample set containing positive and negative samples for each type of gas user based on the standard flow increment sequence. Each training sample in the fault detection sample set contains three flow increment subsequences extracted from the standard flow increment sequence before the detection time, short-term flow information, time coding information, and a label representing whether there is a meter fault at the detection time. The three flow increment subsequences have different sequence lengths. The short-term flow information consists of several flow increment values closest to the detection time in the standard flow increment sequence before the detection time. The time coding information includes a first coding information indicating whether the detection time is a weekday and a second coding information indicating whether the detection time is a holiday. The model training module is used to train a multi-XGBoost fusion fault detection model for each type of gas user using its corresponding fault detection sample set. The multi-XGBoost fusion fault detection model comprises an input layer, an XGBoost layer, a fully connected layer, and an output layer. The input layer is used to input the traffic increment subsequence before the time to be detected. The XGBoost layer contains three XGBoost models, each of which takes the traffic increment subsequence as input and outputs a label representing whether a meter fault exists at the time to be detected. The lengths of the input traffic increment subsequences in the three XGBoost models in the XGBoost layer are different. The input to the fully connected layer is the three labels, short-term traffic information, and time coding information output by the three XGBoost models, and the output is the final fault detection result. The meter fault prediction module is used to acquire three flow increment subsequences, short-term flow information, and time-coding information for a target gas user before a target time, with the length of the three flow increment subsequences being consistent with the sequence length in the training samples. Based on the gas user category to which the target gas user belongs, the acquired three flow increment subsequences, short-term flow information, and time-coding information are input into the multi-XGBoost fusion fault detection model corresponding to that gas user category to predict whether a meter fault will occur in the future.
12. A computer electronic device, characterized in that, Including memory and processor; The memory is used to store computer programs; The processor is configured to implement the gas meter fault detection method based on multi-model fusion as described in any one of claims 1 to 10 when executing the computer program.
Citation Information
Patent Citations
Mixed failure detection diagnosis method based on logical deduction and failure identification
CN102722722A
Gas usage monitoring system and method
CN112032566A