Natural gas abnormal transmission difference analysis method and device, electronic equipment and storage medium
By constructing a target decision tree to analyze natural gas transmission discrepancies, and using the C4.5 algorithm and ensemble learning method to automatically diagnose transmission discrepancies anomalies, the inefficiency of existing technologies is solved, and fast and accurate transmission discrepancy analysis is achieved.
Patent Information
- Application Number
- CN202411153736.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2026-03-03
AI Technical Summary
Existing technologies for analyzing natural gas transmission discrepancies are inefficient, unable to quickly pinpoint problems and their causes, resulting in significant consumption of human and material resources, and relying on human experience, which leads to large errors.
By acquiring historical anomaly data of natural gas transmission discrepancies, a target decision tree is constructed. Real-time data is then analyzed using the C4.5 algorithm and ensemble learning method to automatically diagnose anomalies.
It improves the efficiency and accuracy of differential analysis, reduces human error, shortens the problem location time from several days to tens of minutes, and reduces diagnostic costs.
Smart Images

Figure CN121599262A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a method, apparatus, electronic device, and storage medium for analyzing abnormal natural gas transmission. Background Technology
[0002] In the process of natural gas extraction, storage, and transportation, losses are unavoidable. The so-called "transmission difference" refers to the difference between the input and output of oil and gas pipelines within a certain statistical period under standard reference conditions. For natural gas companies with annual production and sales of hundreds of millions of cubic meters, even a 0.1% change in the transmission difference rate can have a significant impact. Therefore, effectively managing transmission differences not only helps reduce costs and increase efficiency but also enhances the company's market competitiveness.
[0003] With the improvement of pipeline interconnection and the continuous expansion of user coverage areas, more frequent gas volume allocation is required. These changes place higher demands on the management of transmission discrepancies. However, there are many complex factors affecting transmission discrepancies, including the multi-component characteristics of natural gas itself, the installation conditions and operating conditions of gathering and transmission pipelines, environmental changes, and the accuracy of multi-parameter measurements, all of which can affect the metering results and thus lead to transmission discrepancies.
[0004] Current analyses of natural gas output often rely on management experience, employing a "check the instruments first when a discrepancy occurs" approach to diagnose anomalies. This means initially attributing the anomaly to a problem with the metering instruments. However, in reality, instruments undergo periodic calibration and maintenance, and instrument-related metering errors account for a small percentage of anomalies. This approach is not only inefficient but also prone to repeatedly checking the same locations. Since many natural gas stations and pipelines are scattered in remote areas, diagnosing instrument problems requires significant manpower, testing equipment, and vehicle costs, undoubtedly increasing resource consumption. Furthermore, besides damage to metering equipment caused by improper operation or sudden external changes, the current discrepancy handling process is cumbersome and unable to quickly pinpoint the problem and its cause. Therefore, current methods for analyzing natural gas output suffer from low analytical efficiency. Summary of the Invention
[0005] To overcome the problems existing in related technologies, this disclosure provides a method, apparatus, electronic device and storage medium for analyzing abnormal natural gas transmission.
[0006] In a first aspect, embodiments of this application provide a method for analyzing abnormal natural gas transmission losses, including:
[0007] Obtain historical anomaly data for natural gas transmission discrepancies;
[0008] Based on the aforementioned historical anomaly data, a target decision tree is constructed;
[0009] Real-time data collected during natural gas transportation is input into the root node of the target decision tree, so that the real-time data can be analyzed for anomalies through the nodes at each level of the target decision tree, and the anomaly analysis results can be output through the leaf nodes of the target decision tree.
[0010] Optionally, the number of historical anomaly data points is multiple, and the historical anomaly data points include the feature attribute values of each feature attribute among multiple feature attributes. The step of constructing a target decision tree based on the historical anomaly data includes:
[0011] For each historical anomalous data point among multiple historical anomalous data points, key features of the historical anomalous data point are determined based on multiple feature attribute values in the historical anomalous data point, and the key features characterize the anomalous category of the historical anomalous data point.
[0012] Based on multiple feature attribute values and key features of the historical anomaly data, a training data set corresponding to the historical anomaly data is constructed.
[0013] A target decision tree is constructed based on the training data set corresponding to each historical anomaly data.
[0014] Optionally, determining the key features of the historical anomaly data based on multiple feature attribute values in the historical anomaly data includes:
[0015] The C4.5 algorithm combined with ensemble learning method is used to perform feature analysis on multiple feature attribute values in the historical anomaly data to obtain the key features of the historical anomaly data.
[0016] Optionally, constructing the target decision tree based on the historical anomaly data includes:
[0017] For each of the aforementioned feature attributes, the gain ratio of the feature attribute is calculated using the C4.5 algorithm;
[0018] Based on the gain ratio, a target decision tree is constructed.
[0019] Optionally, constructing the target decision tree based on the gain ratio includes:
[0020] Create the root node of the target decision tree;
[0021] The feature attribute with the largest gain ratio in each training data group is taken as the target feature attribute, and the target feature attribute is deleted from its corresponding training data group to obtain the initial training data group.
[0022] Based on the feature attribute values of the target feature attributes, a first-level node is created, which is the next level node of the root node;
[0023] The feature attribute with the largest gain ratio in each of the initial training data sets is taken as the new target feature attribute;
[0024] The new target feature attribute is removed from its corresponding initial training data set to obtain the updated initial training data set.
[0025] Based on the feature attribute values of the new target feature attributes, a second-level node is created, which is the next level node of the first-level node;
[0026] Based on the updated initial training data set, the step of obtaining the feature attribute with the largest gain ratio in each initial training data set as the new target feature attribute is repeated until the number of feature attributes in each updated training data set is 0, so as to obtain the target decision tree.
[0027] Optionally, the step of returning to the step of obtaining the feature attribute with the largest gain ratio in each of the initial training data sets as the new target feature attribute based on the updated initial training data sets, until the number of feature attributes in each of the updated training data sets is 0, to obtain the target decision tree, includes:
[0028] Based on the updated initial training data set, the step of obtaining the feature attribute with the largest gain ratio in each initial training data set as the new target feature attribute is repeated until the number of feature attributes in each updated training data set is 0, thus obtaining the initial decision tree;
[0029] For each leaf node in the last level of the initial decision tree, the attribute category corresponding to the leaf node is determined based on the key features in the training data group to which the stored feature attributes in the leaf node belong.
[0030] After merging all leaf nodes with the same attribute category, the target decision tree is obtained.
[0031] Optionally, creating a first-level node based on the feature attribute values of the target feature attribute includes:
[0032] Create a first child node with the same number of target feature attributes;
[0033] The feature attribute value of each target feature attribute is stored in the first child node to obtain the first level node;
[0034] The creation of a second-level node based on the feature attribute values of the new target feature attributes includes:
[0035] Create a second child node with the same number of the new target feature attributes;
[0036] The feature attribute values of each new target feature attribute are stored in the second child node to obtain the second level node.
[0037] Optionally, the step of inputting real-time data collected during natural gas transportation into the root node of the target decision tree, so as to perform anomaly analysis on the real-time data through each level of the target decision tree, and output the anomaly analysis results through the leaf nodes of the target decision tree, includes:
[0038] Real-time data collected during natural gas transportation is input into the root node of the target decision tree;
[0039] The real-time attribute value corresponding to the feature attribute of the first child node is extracted from the real-time data through the first child node of the lower-level node of the root node;
[0040] The real-time attribute value is compared with the feature attribute value stored in the first child node, and based on the comparison result, the second child node at the next level below the first child node to be transmitted to the real-time data is determined.
[0041] The new real-time attribute value corresponding to the feature attribute of the second child node is extracted from the real-time data through the second child node;
[0042] Based on the new real-time attribute value, return to the step of comparing the real-time attribute value with the feature attribute value stored in the first child node, and determine the second child node at the next level below the first child node to which the real-time data will be transmitted, until the real-time data is transmitted to the leaf node of the target decision tree;
[0043] The attribute category corresponding to the leaf node to which the real-time data will be transmitted is determined as the anomaly analysis result, and the anomaly analysis result is output.
[0044] Optionally, the historical anomaly data includes temperature, pressure, pressure difference, and the time and location at which the historical anomaly data was generated.
[0045] Secondly, embodiments of this application provide a natural gas anomaly transmission analysis device, comprising:
[0046] The acquisition module is used to acquire historical anomaly data related to natural gas transmission discrepancies.
[0047] The construction module is used to construct a target decision tree based on the historical anomaly data;
[0048] The analysis module is used to input real-time data collected during natural gas transportation into the root node of the target decision tree, so as to perform anomaly analysis on the real-time data through the nodes at each level of the target decision tree, and output the anomaly analysis results through the leaf nodes of the target decision tree.
[0049] Thirdly, embodiments of this application provide an electronic device including a processor and a memory, the memory storing a plurality of computer instructions; the processor loads the computer instructions from the memory to execute the steps in the natural gas anomaly transmission difference analysis method as described in the first aspect.
[0050] Fourthly, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions adapted to be loaded by a processor to execute the natural gas anomaly transmission analysis method described in the first aspect.
[0051] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: acquiring historical anomaly data on natural gas transmission discrepancies; constructing a target decision tree based on the historical anomaly data; inputting real-time data collected during natural gas transportation into the root node of the target decision tree, so as to perform anomaly analysis on the real-time data through each level of the target decision tree, and outputting the anomaly analysis results through the leaf nodes of the target decision tree. This enables automatic layer-by-layer analysis of real-time data collected during natural gas transportation using each level of the target decision tree constructed based on historical anomaly data, to accurately output anomaly analysis results, avoiding errors caused by human analysis, and improving the efficiency and accuracy of transmission discrepancy analysis.
[0052] Other features and advantages of this disclosure will be described in detail in the following detailed description section. Attached Figure Description
[0053] The accompanying drawings are provided to further illustrate the present disclosure and form part of the specification. They are used together with the following detailed description to explain the present disclosure, but do not constitute a limitation thereof. In the drawings:
[0054] Figure 1 This is a flowchart illustrating a method for analyzing abnormal natural gas transmission rates according to an exemplary embodiment;
[0055] Figure 2 This is a target decision tree illustrated according to an exemplary embodiment;
[0056] Figure 3 This is an implementation flowchart of a natural gas anomaly transmission difference analysis method according to an exemplary embodiment;
[0057] Figure 4This is a schematic diagram of a natural gas anomaly transmission error analysis device according to an exemplary embodiment;
[0058] Figure 5 This is a schematic diagram of the structure of an electronic device according to an exemplary embodiment. Detailed Implementation
[0059] The specific embodiments of this disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are for illustration and explanation only and are not intended to limit this disclosure.
[0060] Given society's increasing reliance on natural gas, losses caused by transmission discrepancies deserve particular attention. Aside from damage to metering equipment due to human error or sudden external changes, under normal circumstances, analyzing and assessing pipeline operational risks and conducting timely pipeline cleaning and maintenance can improve the stability of natural gas transportation and reduce transmission discrepancies. However, current transmission discrepancy handling procedures are cumbersome and cannot quickly pinpoint the problem and its cause.
[0061] For example, a method for optimizing the calculation of natural gas pipeline transmission difference has been proposed in related technologies. This method improves the calculation efficiency by establishing a visualization model and a system calculation model and by using the fourth-order Runge-Kutta method. However, it only solves the problems of calculation accuracy and calculation efficiency.
[0062] However, in the actual natural gas transportation process, there are many reasons for transmission discrepancies (metering errors, pipeline leaks, process switching, etc.), and automated diagnosis and rapid location of transmission discrepancies are needed to deal with problems in a timely manner and reduce losses.
[0063] To address the aforementioned issues, this embodiment provides a method for analyzing abnormal natural gas transmission discrepancies.
[0064] It should be noted that all data in this disclosure was collected in accordance with the relevant data protection laws and policies of the country where the data is located, and with the authorization of the respective device owner.
[0065] Figure 1 This is a flowchart illustrating a natural gas anomaly transmission error analysis method according to an exemplary embodiment, such as... Figure 1 As shown, the method may include the following steps:
[0066] 110. Obtain historical anomaly data for natural gas transmission discrepancies.
[0067] Historical anomaly data may include, but is not limited to: temperature, pressure, pressure difference, the time and location of the occurrence of the aforementioned historical anomaly data.
[0068] For example, historical anomaly data, such as temperature (GQWD), pressure (GQYL), and pressure difference (GQYC), can be automatically collected from various transmission points in the pipeline network using sensor devices. These parameters can be used as feature attributes (or feature dimensions). Furthermore, the historical anomaly data can also record and save information such as the time, frequency, and cause of the anomaly.
[0069] The location where abnormal data is generated can be determined based on pre-defined input error points, and each input error point has its corresponding location pre-recorded.
[0070] 120. Based on the above historical anomaly data, construct the target decision tree.
[0071] In some implementations, the number of historical anomaly data points is multiple, and these historical anomaly data points include the feature attribute values of each of the multiple feature attributes. A specific implementation of the step "constructing a target decision tree based on the aforementioned historical anomaly data" may include:
[0072] 121. For each historical abnormal data in multiple historical abnormal data, determine the key features of the historical abnormal data based on multiple feature attribute values in the historical abnormal data, and the key features characterize the abnormal category of the historical abnormal data.
[0073] As an example, a historical anomaly data may have multiple characteristic attribute values (such as transmission difference point, pressure difference, temperature, transmission difference rate, etc.), such as the characteristic attribute value of transmission difference point (1), the characteristic attribute value of pressure difference (0.64), the characteristic attribute value of temperature (27℃), the characteristic attribute value of transmission difference rate (-2.20%), etc.
[0074] The specific implementation method for determining the key features of the aforementioned historical anomaly data based on multiple feature attribute values may include:
[0075] The C4.5 algorithm combined with ensemble learning was used to perform feature analysis on multiple feature attribute values in the aforementioned historical anomaly data, thereby obtaining the key features of the aforementioned historical anomaly data.
[0076] Among them, the C4.5 algorithm is a machine learning algorithm used to generate decision trees, mainly for classification tasks. It can predict the category of new samples by constructing decision trees.
[0077] Ensemble learning is a machine learning technique that achieves better predictive performance by building and combining multiple learners.
[0078] For example, if multiple feature attributes in historical anomaly data are temperature, pressure, and pressure difference of a transmission point, the anomaly category corresponding to the transmission point can be obtained by analyzing the temperature, pressure, and pressure difference using the C4.5 algorithm combined with ensemble learning methods, and the anomaly category can be used as the key feature.
[0079] 122. Based on the multiple feature attribute values and key features of the above-mentioned historical abnormal data, construct the training data set corresponding to the above-mentioned historical abnormal data.
[0080] For example, a training data set may include feature attribute value 1, feature attribute value 2, feature attribute value 3, and key features, wherein the key features are determined based on feature attribute value 1, feature attribute value 2, and feature attribute value 3.
[0081] 123. Construct a target decision tree based on the training data set corresponding to each historical abnormal data.
[0082] In some implementations, the specific methods for constructing a target decision tree based on the aforementioned historical anomaly data may include:
[0083] A1. For each of the above-mentioned feature attributes, calculate the gain ratio of the above-mentioned feature attribute using the C4.5 algorithm.
[0084] For example, in step A1, a specific implementation of calculating the gain ratio of the aforementioned feature attribute using the C4.5 algorithm may include:
[0085] Each of the above feature attributes is treated as message information, and the n key features are treated as category attributes, and the following definition is established:
[0086] Definition 1.555 If there are n messages with the same probability, then the probability p of each message is 1 / n, and the amount of information conveyed by a message is -log2(p).
[0087] Definition 2: If a given probability distribution p = (p1, P2, ..., Pn) is given, the amount of information transmitted is called the entropy of p, i.e.:
[0088] I(P)=-(p1×log2(p1)+p2*log2(p2)+...+pn*log2(pn))
[0089] Definition 3: If a set T of records is divided into mutually independent classes C1, C2, C3, ..., CK based on the values of its categorical attribute, then the amount of information required to identify which class an element in T belongs to is Info(T) = I(P), where P is the probability distribution of (C1, C2, C3, ..., CK), i.e.:
[0090] P=(|C1| / |T|, |C2| / |T|, ..., |Ck| / |T|)
[0091] Definition 4: If T is first divided into sets T1, T2, ..., Tn based on the values of non-categorical attributes X, then a piece of information is obtained by the weighted average of T, i.e., the weighted average of Info(T) is:
[0092] Info(X,T)=Σ|Ti| / |T|×Info(Ti)
[0093] Definition 5 defines the gain Gain(X, T) as:
[0094] Gain(X,T)=Info(T)-Info(X,T)
[0095] In other words, the gain is defined as the difference between two pieces of information. One piece of information is the amount of information needed to determine an element of T (such as the feature attribute mentioned above), and the other piece of information is the amount of information needed to determine an element of T after the value of attribute X has been obtained. That is, information gain is related to attribute X.
[0096] Definition 6 defines the gain ratio as:
[0097] Gain(X, T) = GainRatio(X, T) = Splitlnfo(X, T). Since T is classified based on the value of attribute X, Splinfo(X, T) is the information content. Therefore, Splitlnfo(X, T) is l(|T1| / |T|, |T2| / |T|, ..., |Tn| / |T|), where {T1, T2, ..., Tn} are subsets of T generated by splitting T according to the value of X.
[0098] As can be seen, the gain ratio of a feature attribute can be calculated using the C4.5 algorithm based on the above definition. It is understandable that calculating the gain ratio using the C4.5 algorithm is a common technique; a more detailed calculation process will not be elaborated here.
[0099] A2. Based on the above gain ratio, construct the target decision tree.
[0100] In step A2, the specific implementation method for constructing the target decision tree based on the above gain ratio may include:
[0101] A21. Create the root node of the above target decision tree.
[0102] A22. Obtain the feature attribute with the largest gain ratio in each of the above training data groups as the target feature attribute, and delete the above target feature attribute from its corresponding training data group to obtain the initial training data group.
[0103] A23. Based on the feature attribute values of the target feature attributes mentioned above, create a first-level node. The first-level node is the next level node of the root node mentioned above.
[0104] In step A23, the specific implementation method for creating the first-level node based on the feature attribute values of the aforementioned target feature attributes may include:
[0105] Create a first child node with the same number of target feature attributes as described above.
[0106] The feature attribute values of each of the above target feature attributes are stored in the first child node to obtain the first-level node.
[0107] A24. Obtain the feature attribute with the largest gain ratio in each of the above initial training data sets as the new target feature attribute.
[0108] A25. Delete the new target feature attributes mentioned above from their corresponding initial training data sets to obtain the updated initial training data sets.
[0109] A26. Based on the feature attribute values of the new target feature attributes mentioned above, create a second-level node. The second-level node is the next level node of the first-level node mentioned above.
[0110] In step A26, the creation of a second-level node based on the feature attribute values of the new target feature attributes includes:
[0111] Create a second child node with the same number of the new target feature attributes mentioned above.
[0112] The feature attribute values of each of the above new target feature attributes are stored in the above second child node to obtain the above second-level node.
[0113] A27. Based on the updated initial training data set, return to the step of obtaining the feature attribute with the largest gain ratio in each of the initial training data sets as the new target feature attribute, until the number of feature attributes in each of the updated training data sets is 0, so as to obtain the target decision tree.
[0114] In step A27, the above-mentioned step of retrieving the feature attribute with the largest gain ratio in each of the above-mentioned initial training data sets as the new target feature attribute is performed based on the updated initial training data sets, until the number of feature attributes in each of the above-mentioned updated training data sets is 0, thereby obtaining the target decision tree, including:
[0115] A271. Based on the updated initial training data set, return to the step of obtaining the feature attribute with the largest gain ratio in each of the above initial training data sets as the new target feature attribute, until the number of feature attributes in each of the above updated training data sets is 0, and obtain the initial decision tree.
[0116] A272. For each leaf node of the last level in the initial decision tree, determine the attribute category corresponding to the leaf node based on the key features in the training data group to which the stored feature attributes belong.
[0117] Among them, the attribute category can also represent the abnormal category of the transmission error. The specific classification of this attribute category can be customized according to actual needs. For example, it can be classified as normal or abnormal based on whether it is abnormal, as mild or severe based on the degree of abnormality, or as pipeline abnormality or metering abnormality based on the origin of the abnormality. No limitation is made here.
[0118] A273. After merging all leaf nodes with the same attribute category, the above target decision tree is obtained.
[0119] In some implementations, when creating the root node, the feature attribute with the largest gain ratio in each of the above training data sets can be used as the root node of the target decision tree, and then the lower-level nodes of the root node can continue to be created in the same way as the first-level and second-level nodes.
[0120] For example, multiple training data sets as shown in Table 1 can be constructed using historical anomaly data. The following uses Table 1 as an example to perform the operation of constructing the target decision tree in step A2.
[0121] Table 1
[0122]
[0123] In Table 1, each row can be viewed as a training data set (array).
[0124] For example, the process of constructing a target decision tree based on the data in Table 1 can be as follows:
[0125] 1. Create a root node, whose array is set as a collection of exception categories (SCLB) according to different exception categories.
[0126] Second: Calculate each feature attribute (hereinafter also referred to as attribute) in each array and find the feature attribute with the largest (gain ratio) GainRatio.
[0127] 3. Assign this attribute name to the current name. Insert as many child nodes as there are attribute values. Assign the attribute value to the value of the child node. At the same time, increment the node count by 1 for each inserted node and insert the node into the queue.
[0128] 4. Remove this element from the attribute array.
[0129] 5. Take a point from the queue and recursively perform steps 2 to 4 until the array is empty.
[0130] 6. Assign a category attribute to each leaf node and merge attributes of the same category to construct the target decision tree. For example, the constructed target decision tree can be as follows: Figure 2 As shown, in this target decision tree, the feature attribute corresponding to the root node can be temperature (GQWD), the feature attribute corresponding to the next level node of the root node can be pressure difference (GQYC), the next level node of pressure difference (GQYC) can be the child node corresponding to the feature attribute of abnormality degree (such as low abnormality degree, normal abnormality degree, high abnormality degree), and the leaf node in this target decision tree can be the abnormal category of the category attribute.
[0131] 130. Input the real-time data collected during the natural gas transportation process into the root node of the above-mentioned target decision tree, so as to perform anomaly analysis on the real-time data through the nodes at each level of the above-mentioned target decision tree, and output the anomaly analysis results through the leaf nodes of the above-mentioned target decision tree.
[0132] In step 130, the real-time data collected during natural gas transportation is input into the root node of the target decision tree to perform anomaly analysis on the real-time data through each level of the target decision tree, and the anomaly analysis results are output through the leaf nodes of the target decision tree. A specific implementation of this method may include:
[0133] Real-time data collected during natural gas transportation is input into the root node of the aforementioned target decision tree.
[0134] The real-time attribute values corresponding to the feature attributes of the first child node in the lower-level nodes of the root node are extracted from the real-time data.
[0135] The real-time attribute values are compared with the feature attribute values stored in the first child node, and based on the comparison results, the second child node at the next level below the first child node to which the real-time data will be transmitted is determined.
[0136] The second child node is used to extract new real-time attribute values from the real-time data that correspond to the feature attributes of the second child node.
[0137] Based on the new real-time attribute values, the process returns to the step of comparing the real-time attribute values with the feature attribute values stored in the first child node, and determining the second child node at the next level below the first child node to which the real-time data will be transmitted, until the real-time data is transmitted to the leaf node of the target decision tree.
[0138] The attribute category corresponding to the leaf node to which the above real-time data will be transmitted is determined as the above anomaly analysis result, and the above anomaly analysis result is output.
[0139] Continue using the above Figure 2 For example, the specific implementation of step 130 can be shown in steps seven to eleven below:
[0140] 7. Obtain real-time data on transmission anomalies involved in the natural gas extraction process.
[0141] 8. Input the real-time data into the root node of the decision tree.
[0142] 9. Obtain real-time data for the corresponding attributes based on the characteristic attributes stored in each node.
[0143] 10. Select the output branch according to the attribute values of the corresponding attributes mentioned above until the leaf node is reached, and output the running category stored in the leaf node as the analysis result.
[0144] 11. If there is an abnormality, the cause of the output error.
[0145] As a more specific example, such as Figure 3 As shown, the specific implementation process of steps 110 to 130 can be as follows: Figure 3 As shown:
[0146] First, it automatically obtains historical data on temperature, pressure, and causes of abnormalities from a period prior to the input anomaly. This includes data such as pressure, temperature, and the type of abnormality.
[0147] Then, the obtained alarm data and the cause of the anomaly are used as training tuples (such as the training data group mentioned above). The training tuples are divided according to the anomaly attribute, feature attributes are extracted, the feature attribute with the largest gain ratio is found, and a decision tree is constructed based on the feature attribute.
[0148] Finally, the decision tree algorithm is used to extract daily data and input it into the root node of the decision tree. The output branch is selected according to the real-time attribute value of the pipeline running corresponding to the feature attribute stored in each node (such as comparing the feature attribute value stored in each node with the input real-time attribute value and selecting the output branch) until the leaf node is reached. The analysis results are output according to the content stored in the leaf node.
[0149] As can be seen, the natural gas anomaly transmission difference analysis method implemented in this paper acquires historical anomaly data on natural gas transmission differences; constructs a target decision tree based on the historical anomaly data; and inputs real-time data collected during natural gas transportation into the root node of the target decision tree. Anomaly analysis is then performed on the real-time data through each level of the target decision tree, and the anomaly analysis results are output through the leaf nodes of the target decision tree. This allows for automatic layer-by-layer analysis of real-time data collected during natural gas transportation using the target decision tree constructed from historical anomaly data, resulting in accurate anomaly analysis results. This avoids errors caused by human analysis and improves the efficiency and accuracy of transmission difference analysis.
[0150] Specifically, this solution improves the efficiency of diagnosing natural gas transmission anomalies. Compared to related technologies, diagnosing and handling transmission anomalies may take one to twenty days. Using the analysis method in this embodiment, problems can be quickly detected, accurately located, and solutions proposed, reducing processing time to within tens of minutes. Furthermore, it reduces the cost of diagnosing natural gas transmission anomalies: since natural gas production stations are mostly located in remote areas, one-way travel time can sometimes take several hours, and there are numerous metering entry and exit points for transmission lines, frequent trips to the site lead to significant consumption of personnel, testing equipment, and vehicle resources. With this solution, when faced with transmission anomalies, staff no longer need to blindly and repeatedly search for causes or travel back and forth to the site, potentially overlooking crucial steps. Instead, they can systematically handle problems based on the system's output, significantly reducing arbitrariness in the diagnostic process, saving unnecessary costs, and greatly reducing the complexity of problem investigation for frontline personnel.
[0151] To better implement the above methods, this application also provides a natural gas anomaly transmission analysis device. This device can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet, smart Bluetooth device, laptop, or personal computer; the server can be a single server or a server cluster consisting of multiple servers.
[0152] For example, in this embodiment, the method of the present application will be described in detail by taking the natural gas abnormal transmission difference analysis device specifically integrated into an electronic device.
[0153] For example, such as Figure 4 As shown, the natural gas anomaly transmission analysis device may include
[0154] The acquisition module is used to acquire historical anomaly data related to natural gas transmission discrepancies.
[0155] The building module is used to construct a target decision tree based on historical anomaly data;
[0156] The analysis module is used to input real-time data collected during natural gas transportation into the root node of the target decision tree, so that the real-time data can be analyzed for anomalies through the nodes at each level of the target decision tree, and the anomaly analysis results can be output through the leaf nodes of the target decision tree.
[0157] In some implementations, the number of historical anomaly data points is multiple, and the historical anomaly data includes the feature attribute value of each feature attribute among multiple feature attributes. The construction module is specifically used for:
[0158] For each historical anomalous data point among multiple historical anomalous data points, key features of the historical anomalous data point are determined based on multiple feature attribute values in the historical anomalous data point. These key features characterize the anomalous category of the historical anomalous data point.
[0159] Based on multiple feature attribute values and key features of historical anomaly data, a training data set corresponding to the historical anomaly data is constructed.
[0160] A target decision tree is constructed based on the training data set corresponding to each historical anomaly data.
[0161] In some implementations, the building module is further used for:
[0162] The C4.5 algorithm combined with ensemble learning method is used to perform feature analysis on multiple feature attribute values in historical anomaly data to obtain the key features of historical anomaly data.
[0163] In some implementations, the building module is further used for:
[0164] For each feature attribute, the gain ratio of the feature attribute is calculated using the C4.5 algorithm;
[0165] Based on the gain ratio, construct the target decision tree.
[0166] In some implementations, the building module is further used for:
[0167] Create the root node of the target decision tree;
[0168] The feature attribute with the largest gain ratio in each training data set is taken as the target feature attribute, and the target feature attribute is removed from its corresponding training data set to obtain the initial training data set.
[0169] Based on the feature attribute values of the target feature attributes, create a first-level node, which is the next level node of the root node;
[0170] The feature attribute with the largest gain ratio in each initial training data set is taken as the new target feature attribute.
[0171] The new target feature attribute is removed from its corresponding initial training data set to obtain the updated initial training data set.
[0172] Based on the feature attribute values of the new target feature attributes, create a second-level node, which is the next level node of the first-level node;
[0173] Based on the updated initial training data set, the process of retrieving the feature attribute with the largest gain ratio in each initial training data set as the new target feature attribute continues until the number of feature attributes in each updated training data set is 0, in order to obtain the target decision tree.
[0174] In some implementations, the building module is further used for:
[0175] Based on the updated initial training data set, the process of retrieving the feature attribute with the largest gain ratio in each initial training data set as the new target feature attribute continues until the number of feature attributes in each updated training data set is 0, thus obtaining the initial decision tree;
[0176] For each leaf node in the last level of the initial decision tree, the attribute category corresponding to the leaf node is determined based on the key features in the training data group to which the feature attributes stored in the leaf node belong.
[0177] After merging all leaf nodes with the same attribute category, the target decision tree is obtained.
[0178] In some implementations, the building module is further used for:
[0179] Create a first child node with the same number of target feature attributes;
[0180] The feature attribute value of each target feature attribute is stored in the first child node to obtain the first-level node;
[0181] Based on the feature attribute values of the new target feature attributes, create second-level nodes, including:
[0182] Create a second child node with the same number of new target feature attributes;
[0183] The feature attribute value of each new target feature attribute is stored in the second child node to obtain the second-level node.
[0184] In some implementations, the analysis module is specifically used for:
[0185] Real-time data collected during natural gas transportation is input into the root node of the target decision tree;
[0186] Extract the real-time attribute value of the feature attribute corresponding to the first child node from the real-time data through the first child node of the root node;
[0187] The real-time attribute values are compared with the feature attribute values stored in the first child node, and based on the comparison results, the second child node, which is one level below the first child node, is determined to be the next real-time data to be transmitted.
[0188] The new real-time attribute value corresponding to the feature attribute of the second child node is extracted from the real-time data through the second child node;
[0189] Based on the new real-time attribute value, return to the step of comparing the real-time attribute value with the feature attribute value stored in the first child node, and determine the second child node at the next level below the first child node to which the real-time data will be transmitted, until the real-time data is transmitted to the leaf node of the target decision tree.
[0190] The attribute category corresponding to the leaf node to which the real-time data will be transmitted is determined as the anomaly analysis result, and the anomaly analysis result is output.
[0191] In some implementations, historical anomaly data includes temperature, pressure, pressure difference, and the time and location where the historical anomaly data was generated.
[0192] In practice, each of the above units can be implemented as an independent entity or can be arbitrarily combined to be implemented as the same or several entities. For the specific implementation of each of the above units, please refer to the previous method embodiments, which will not be repeated here.
[0193] This application also provides an electronic device, such as... Figure 5 As shown, it illustrates a structural schematic diagram of the electronic device involved in the embodiments of this application, specifically:
[0194] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, an input module 404, and a communication module 405. Those skilled in the art will understand that... Figure 5 The electronic device structure shown does not constitute a limitation on the electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0195] The processor 401 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 402, and by calling data stored in the memory 402, it performs various functions and processes data, thereby performing overall detection of the electronic device. In some embodiments, the processor 401 may include one or more processing cores; in some embodiments, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 401.
[0196] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and natural gas anomaly analysis by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function, etc.; the data storage area may store data created based on the use of electronic devices, etc. In addition, the memory 402 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0197] The electronic device also includes a power supply 403 that supplies power to the various components. In some embodiments, the power supply 403 can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 403 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0198] The electronic device may also include an input module 404, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0199] The electronic device may also include a communication module 405. In some embodiments, the communication module 405 may include a wireless module. The electronic device can perform short-range wireless transmission through the wireless module of the communication module 405, thereby providing users with wireless broadband Internet access.
[0200] Although not shown, the electronic device may also include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 401 in the electronic device loads the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following computer instructions, and the processor 401 runs the application programs stored in the memory 402, thereby realizing the various functions in the embodiments of this application.
[0201] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0202] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by computer instructions, or by controlling related hardware with computer instructions. The computer instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0203] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of computer instructions that can be loaded by a processor to execute the steps in any of the natural gas anomaly transmission difference analysis methods provided in embodiments of this application.
[0204] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0205] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in the above embodiments.
[0206] Since the computer instructions stored in the storage medium can execute the steps in any of the natural gas anomaly transmission difference analysis methods provided in the embodiments of this application, the beneficial effects that any of the natural gas anomaly transmission difference analysis methods provided in the embodiments of this application can achieve can be realized. For details, please refer to the previous embodiments, which will not be repeated here.
[0207] The preferred embodiments of this disclosure have been described in detail above with reference to the accompanying drawings. However, this disclosure is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this disclosure, various simple modifications can be made to the technical solutions of this disclosure, and these simple modifications all fall within the protection scope of this disclosure.
[0208] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, this disclosure will not describe the various possible combinations separately.
[0209] Furthermore, various different embodiments of this disclosure can be combined in any way, as long as they do not violate the spirit of this disclosure, they should also be regarded as the content disclosed in this disclosure.
Claims
1. A method for analyzing abnormal natural gas transmission discrepancies, characterized in that, include: Obtain historical anomaly data for natural gas transmission discrepancies; Based on the aforementioned historical anomaly data, a target decision tree is constructed; Real-time data collected during natural gas transportation is input into the root node of the target decision tree, so that the real-time data can be analyzed for anomalies through the nodes at each level of the target decision tree, and the anomaly analysis results can be output through the leaf nodes of the target decision tree.
2. The method according to claim 1, characterized in that, The number of historical anomaly data points is multiple, and each historical anomaly data point includes the feature attribute value of each feature attribute among multiple feature attributes. The step of constructing a target decision tree based on the historical anomaly data includes: For each historical anomalous data point among multiple historical anomalous data points, key features of the historical anomalous data point are determined based on multiple feature attribute values in the historical anomalous data point, and the key features characterize the anomalous category of the historical anomalous data point. Based on multiple feature attribute values and key features of the historical anomaly data, a training data set corresponding to the historical anomaly data is constructed. A target decision tree is constructed based on the training data set corresponding to each historical anomaly data.
3. The method according to claim 2, characterized in that, The step of determining the key features of the historical abnormal data based on multiple feature attribute values in the historical abnormal data includes: The C4.5 algorithm combined with ensemble learning method is used to perform feature analysis on multiple feature attribute values in the historical anomaly data to obtain the key features of the historical anomaly data.
4. The method according to claim 3, characterized in that, The construction of the target decision tree based on the historical anomaly data includes: For each of the aforementioned feature attributes, the gain ratio of the feature attribute is calculated using the C4.5 algorithm; Based on the gain ratio, a target decision tree is constructed.
5. The method according to claim 4, characterized in that, The construction of the target decision tree based on the gain ratio includes: Create the root node of the target decision tree; The feature attribute with the largest gain ratio in each training data group is taken as the target feature attribute, and the target feature attribute is deleted from its corresponding training data group to obtain the initial training data group. Based on the feature attribute values of the target feature attributes, a first-level node is created, which is the next level node of the root node; The feature attribute with the largest gain ratio in each of the initial training data sets is taken as the new target feature attribute; The new target feature attribute is removed from its corresponding initial training data set to obtain the updated initial training data set. Based on the feature attribute values of the new target feature attributes, a second-level node is created, which is the next level node of the first-level node; Based on the updated initial training data set, the step of obtaining the feature attribute with the largest gain ratio in each initial training data set as the new target feature attribute is repeated until the number of feature attributes in each updated training data set is 0, so as to obtain the target decision tree.
6. The method according to claim 5, characterized in that, The step of returning to the previous step of obtaining the feature attribute with the largest gain ratio in each of the initial training data sets as the new target feature attribute, based on the updated initial training data sets, continues until the number of feature attributes in each of the updated training data sets is 0, thus obtaining the target decision tree, including: Based on the updated initial training data set, the step of obtaining the feature attribute with the largest gain ratio in each initial training data set as the new target feature attribute is repeated until the number of feature attributes in each updated training data set is 0, thus obtaining the initial decision tree; For each leaf node in the last level of the initial decision tree, the attribute category corresponding to the leaf node is determined based on the key features in the training data group to which the stored feature attributes in the leaf node belong. After merging all leaf nodes with the same attribute category, the target decision tree is obtained.
7. The method according to claim 6, characterized in that, The step of creating a first-level node based on the feature attribute values of the target feature attributes includes: Create a first child node with the same number of target feature attributes; The feature attribute value of each target feature attribute is stored in the first child node to obtain the first level node; The creation of a second-level node based on the feature attribute values of the new target feature attributes includes: Create a second child node with the same number of the new target feature attributes; The feature attribute values of each new target feature attribute are stored in the second child node to obtain the second level node.
8. The method according to claim 7, characterized in that, The process of collecting real-time data during natural gas transportation is input into the root node of the target decision tree. Anomaly analysis is then performed on the real-time data through each level of the target decision tree, and the anomaly analysis results are output through the leaf nodes of the target decision tree. This includes: Real-time data collected during natural gas transportation is input into the root node of the target decision tree; The real-time attribute value corresponding to the feature attribute of the first child node is extracted from the real-time data through the first child node of the lower-level node of the root node; The real-time attribute value is compared with the feature attribute value stored in the first child node, and based on the comparison result, the second child node at the next level below the first child node to be transmitted to the real-time data is determined. The new real-time attribute value corresponding to the feature attribute of the second child node is extracted from the real-time data through the second child node; Based on the new real-time attribute value, return to the step of comparing the real-time attribute value with the feature attribute value stored in the first child node, and determine the second child node at the next level below the first child node to which the real-time data will be transmitted, until the real-time data is transmitted to the leaf node of the target decision tree; The attribute category corresponding to the leaf node to which the real-time data will be transmitted is determined as the anomaly analysis result, and the anomaly analysis result is output.
9. The method according to any one of claims 1 to 8, characterized in that, The historical anomaly data includes temperature, pressure, pressure difference, and the time and location of the occurrence of the historical anomaly data.
10. A natural gas anomaly transmission error analysis device, characterized in that, include: The acquisition module is used to acquire historical anomaly data related to natural gas transmission discrepancies. The construction module is used to construct a target decision tree based on the historical anomaly data; The analysis module is used to input real-time data collected during natural gas transportation into the root node of the target decision tree, so as to perform anomaly analysis on the real-time data through the nodes at each level of the target decision tree, and output the anomaly analysis results through the leaf nodes of the target decision tree.
11. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a plurality of computer instructions; the processor loads the computer instructions from the memory to perform the steps in the natural gas anomaly transmission difference analysis method as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The storage medium stores a plurality of instructions, which are adapted to be loaded by a processor to execute the natural gas anomaly transmission difference analysis method according to any one of claims 1 to 9.