A knowledge graph-based fault diagnosis method for dynamometer diagrams
Through the knowledge graph and graph attention network model, the problem of traditional power graph fault diagnosis methods relying on experience and generalization capabilities is solved, and more accurate fault identification and prediction is achieved, and false alarm rates and missed rates are reduced.
Patent Information
- Application Number
- CN202411305392.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-19
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-09-19
AI Technical Summary
The traditional method of fault diagnosis of exercise diagrams depends on the experience of technicians, and lacks generalization ability, which is prone to misdiagnosis or misdiagnosis, and it is difficult to extract features of high-dimensional time series data, resulting in inaccurate fault diagnosis results.
Using a knowledge graph-based method, through data collection, cleaning and standardization processing, entities and attributes are extracted, knowledge graph database is constructed, and the graph attention network model is used to perform power graph fault diagnosis, and the accuracy, recall and F1 of the model are evaluated. Fraction.
Improve data integrity and accuracy, accurately identify and predict pump failures, reduce false alarms and missed alarm rates, and provide more reliable diagnostic results.
Smart Images

Figure CN118820862B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of oil production fault diagnosis, and specifically relates to a dynamometer diagram fault diagnosis method based on knowledge graph. Background Art
[0002] In the field of oil production engineering, the dynamometer diagram is an important tool for detecting the operating status of the pumping unit. It records the displacement and load parameters of the pumping unit during operation. By analyzing and modeling the dynamometer diagram data to identify fault characteristics, the pumping efficiency can be effectively improved, and the future operating status of the pumping unit can be predicted, providing important support for oilfield production management.
[0003] In the traditional dynamometer fault diagnosis method, technicians rely on oil production engineering knowledge to establish typical dynamometer diagrams under different fault conditions, and compare the actual collected dynamometer diagram with the typical dynamometer diagram to determine whether there is a fault and the type of fault. However, the traditional method still has some shortcomings. For example, the traditional method relies too much on the experience and expertise of technicians, and is insufficient in dealing with complex fault modes, which is prone to misdiagnosis or missed diagnosis; training effective machine learning and deep learning models requires a large amount of high-quality data, while the actual field data has problems such as noise and incompleteness, and the model generalization ability is insufficient, resulting in inaccurate diagnosis results; the dynamometer data itself is high-dimensional time series data, how to effectively extract and select features is still a challenge, and the selection of features will affect the diagnosis results of the model. Although the method based on artificial intelligence technology has improved the effect of dynamometer diagnosis to a certain extent, there are still many challenges, resulting in high false alarms and leakage rates of faults.
[0004] With the continuous development and application of technologies such as machine learning and natural language processing, knowledge graph technology has emerged and has become an important technology in the field of artificial intelligence. In the actual production process of oil fields, feature extraction of dynamometer data and accurate prediction of fault types are key steps, but how to effectively extract fault-related features and accurately predict them remains a challenge. Therefore, the use of knowledge graph technology, through deep learning methods, plays an important role in the diagnosis and prediction of dynamometer faults. Summary of the invention
[0005] In order to solve the above problems, the present invention provides a method for diagnosing dynamometer diagram faults based on knowledge graph, which comprises the following steps: firstly, data collection is performed to obtain dynamometer diagram data of the oil pump, dynamometer diagram derived data such as load, and dynamic production data; the collected data are cleaned, main control factors are selected, and standardized; entities and attributes are extracted based on rules, and relationships are extracted using deep learning methods to form a knowledge graph database, and then nodes and edges in the knowledge graph are constructed and the data set is divided; the fault type of the dynamometer diagram is predicted by a deep learning method; and finally, evaluation indicators are selected to evaluate the prediction results of the model.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A method for dynamometer fault diagnosis based on knowledge graph includes the following steps:
[0008] Step 1: collect data, including obtaining the indicator diagram data of the pumping unit, calculating the derived data of the indicator diagram, and collecting production dynamic data;
[0009] Step 2: Data preprocessing, including data cleaning, main control factor selection and standardization of the collected data;
[0010] Step 3: Extract entities, relationships, and attributes, construct a knowledge graph, and divide the data set consisting of the knowledge graph into a training set and a test set;
[0011] Step 4: Build a graph attention network model for dynamometer fault diagnosis and train the model;
[0012] Step 5: Use accuracy, recall, and F1 score to comprehensively evaluate the graph attention network model based on the training set and test set.
[0013] Furthermore, the specific process of step 1 is as follows:
[0014] Step 1.1, collect the data of the indicator diagram, which is a curve describing the relationship between load and displacement during the operation of the pumping unit;
[0015] Step 1.2, calculate the derived data of the indicator diagram according to the indicator diagram data, extract the highest point and the lowest point of the load from the indicator diagram data, and calculate the maximum load and the minimum load respectively; obtain the average load by averaging all the load data in the indicator diagram; calculate the rate of load change by using a differential algorithm to obtain the load change rate; calculate the time of a complete pumping unit working cycle by detecting the periodic change of the indicator diagram to obtain the cycle period; calculate the area enclosed by the indicator diagram by using a numerical integration method to obtain the area of the indicator diagram;
[0016] Step 1.3, collect production dynamic data of other time series and sample data of dynamometer diagram fault types; dynamometer diagram fault types include normal dynamometer diagram, insufficient liquid supply, gas influence, suspected rod breakage, pump collision, sand production, and floating valve leakage; organize the collected data to form a data structure for dynamometer diagram fault diagnosis and build a sample library.
[0017] Furthermore, the specific process of step 2 is as follows:
[0018] Step 2.1: Data cleaning includes cleaning missing values, filling missing contents, and removing unnecessary fields. The filling process is as follows:
[0019] ;
[0020] in, Indicates the position in the data set table The value after missing or zero values at are filled, and Represents the rows and columns in the data set table respectively; Indicates the minimum value of filling; is a random number uniformly drawn from the range [0,1);
[0021] Step 2.2: Based on the feature selection method, the main controlling factors in the collected data are screened. Specifically, the Spearman correlation coefficient is used to screen the features. The formula is:
[0022] ;
[0023] in, is the Spearman rank correlation coefficient, which indicates the correlation between two variables; For two variables in The rank difference among the observations; is the total number of observations; is the sum of the squares of all rank differences;
[0024] Step 2.3: Apply minimum-maximum normalization to the filtered data to linearly map the original data to the range of [0,1]. The specific formula is:
[0025] ;
[0026] in, Represents the eigenvalue after standardization; The raw data representing the eigenvalues; Represents the minimum value in the eigenvalue data; Indicates the maximum value in the eigenvalue data.
[0027] Furthermore, the specific process of step 3 is as follows:
[0028] Step 3.1: The rule-based method directly extracts the unique values of well and fault type from the data as entities, and extracts two entity classes, namely well entity and fault type entity; the entity extraction formula is expressed as:
[0029] ;
[0030] in, is the extracted entity set; is the well entity index, Indicates Well entity; is the fault type index, Indicates Fault type entity; It means extracting unique values from the data as all well entities; It means extracting unique values from the data as all fault type entities; Function is used to extract unique values from a dataset; is a data frame containing the required data; is a data frame containing well data; is a data frame containing fault type data;
[0031] Step 3.2: Based on the number of samples, data structure, and number of entities, use deep learning methods to extract relations. The relation extraction formula is expressed as:
[0032] ;
[0033] in, is the extracted relation set;
[0034] Step 3.3: Attribute extraction also uses a rule-based approach to directly extract attributes and attribute values from the data; the attribute extraction formula is expressed as:
[0035] ;
[0036] in, is the set of extracted attributes; Indicates properties, It is the index or identifier of the attribute, used to distinguish different attributes; Indicates Well Entity No. Attributes The value of For data frame Middle Well Entity and Attributes Specific attribute value of To access an attribute in a data frame, Indicates that the well entity is indexed and Attributes To locate the specific attribute value, the well entity index and Attributes As The column index and column identifier of
[0037] Step 3.4: Use the extracted entities, relationships, and attributes to construct a knowledge graph. The knowledge graph is a graph structure. Each node in the knowledge graph represents a well entity or a fault type entity. Each edge represents the relationship between the well entity and the fault type entity. The node features represent the attributes of the entity. The graph structure formula is as follows:
[0038] ;
[0039] in, Representation diagram; Represents an entity node; represents the extracted relation set;
[0040] Step 3.5: Divide the dataset consisting of the knowledge graph into a training set and a test set.
[0041] Furthermore, in the knowledge graph constructed in step 3.4, the adjacency matrix is used to represent the structure of the graph, and the node feature matrix represents the features of each node, which are respectively represented as follows:
[0042] ;
[0043] in, Represents the adjacency matrix, which is used to express the relationship between nodes in the graph;
[0044] ;
[0045] in, Represents the node feature matrix, which is used to express the attribute characteristics of each node; is the node feature matrix Line The eigenvalues corresponding to the columns.
[0046] Furthermore, the specific process of step 4 is as follows:
[0047] Step 4.1: Build a graph attention network model, which consists of three parts: entity encoder, relation encoder and decoder.
[0048] Step 4.2: During model training, the cross entropy loss function is used to calculate the loss between the model's predicted output and the true label.
[0049] Furthermore, in the entity encoder of the graph attention network model, the influence of different relations in the directed knowledge graph is considered based on the multi-relation heterogeneous graph neural network framework, and the message function is used to pass messages and integrate the process of neighbor entity and relationship embedding. For a given triple , the aggregation of neighbor entities and relationship embeddings of the central node uses the message function To express, in the multi-relation heterogeneous graph neural network framework, the embedding vectors of neighbor entities and relationships are combined using multiplication operations; the aggregation ratio of each neighbor node is dynamically adjusted using the attention mechanism. The attention function uses dot products to measure the similarity between the embedding vectors, and adjusts the calculation process of the attention function through a learnable vector; after aggregating the neighbor node information, the nonlinear activation function ReLU is used to introduce nonlinearity; among them, is the head entity; for relationships; is the tail entity;
[0050] In the relation encoder, a relation is defined as a basis vector, which represents the "direction" of the relation in the relation space. At the same time, an attention mechanism is used to identify and aggregate strongly related neighboring relations. , using the dot product operation to evaluate The similarity between other relations is converted into an attention score through a fully connected layer, and finally the attention score in the attention mechanism is normalized using the Softmax function to finally obtain the attention weight of the relation;
[0051] In the decoder, a convolutional embedding model is used to reshape the embedding vectors of entities and relations into two-dimensional tensors. A convolutional neural network is used to perform convolution operations on the reshaped two-dimensional tensors to extract local features of triples. Finally, a pooling layer is used to reduce the dimension of the feature space.
[0052] The output features of the decoder are mapped to the category space, and the prediction results of the dynamometer fault diagnosis are output. The formula is as follows:
[0053] ;
[0054] in, represents the weight matrix; represents the bias vector; represents the input feature vector; Represents the output vector.
[0055] Furthermore, in step 4.2, the cross entropy loss function formula is as follows:
[0056] ;
[0057] in, is the value of the loss function; is the total number of samples, that is, the number of samples in the data set; is the index of the current tag; Indicates The actual value of the label; Indicates The predicted value of each label;
[0058] The Adam optimizer is used to update the model parameters during the gradient descent process. Adam is an adaptive learning rate optimization algorithm that combines momentum gradient descent and adaptive learning rate adjustment. The formula is as follows:
[0059] ;
[0060] in, Represents the time step The parameter value at that time, that is, the parameter after one update; Represents the time step , that is, the parameter value before this update; represents the learning rate; Represents the time step Momentum at time Represents the time step The first moment estimate when ; represents a small constant used for numerical stability.
[0061] Compared with the prior art, the present invention has the following beneficial effects.
[0062] 1. Knowledge graphs can integrate data from different sources. Through unified data representation and links, they can better mine the associations and correlations between data. Through association analysis of knowledge graphs, anomalies and inconsistencies in data can be discovered, improving data integrity and accuracy. At the same time, it can facilitate data query and analysis, and improve data utilization and work efficiency.
[0063] 2. The knowledge graph encodes and models various entities and attributes in oilfield production to form a rich knowledge base, which contains not only static information of equipment but also dynamic data under different working conditions. On this basis, by extracting features related to pumping unit failures, faults can be identified and predicted more accurately.
[0064] 3. As the basis for building models, knowledge graphs provide rich basic data and features for advanced fault diagnosis models such as deep learning, which can greatly enhance the training effect of models. Knowledge graphs can be continuously updated and expanded, and by introducing new data and features, models can be continuously learned and optimized. The combination of knowledge graphs and deep learning models can effectively reduce the false alarm rate and missed alarm rate in fault diagnosis and provide more reliable diagnostic results. Using methods such as deep learning, the pumping unit fault diagnosis model is continuously optimized and improved to improve its accuracy and reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] Figure 1 It is a flow chart of the dynamometer diagram fault diagnosis method based on the knowledge graph of the present invention.
[0066] Figure 2 It is a data structure diagram of the knowledge graph database of the present invention.
[0067] Figure 3 It is a structural diagram of the relationship extraction model of the present invention.
[0068] Figure 4 It is a structural diagram of the graph attention network model of the present invention.
[0069] Figure 5 It is a diagram of the main controlling factor analysis and screening characteristic results in an embodiment of the present invention.
[0070] Figure 6 1 is a graph showing the model training set loss and test set loss results in an embodiment of the present invention.
[0071] Figure 7 It is a graph of the accuracy results of the model training set and test set in an embodiment of the present invention.
[0072] Figure 8 1 is a graph showing the recall rate results of the model training set and test set in an embodiment of the present invention.
[0073] Fig. 9 1 is a graph of the F1 score results of the model training set and test set in an embodiment of the present invention. DETAILED DESCRIPTION
[0074] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0075] The present invention proposes a method for diagnosing faults of an indicator diagram based on a knowledge graph. First, data collection is performed to obtain the indicator diagram data of the oil pumping unit, and the derivative data of the indicator diagram such as the maximum load and the minimum load are calculated, and other production dynamic data are collected. Secondly, the collected data is cleaned, the main control factors are selected, and standardized. Entities and attributes are extracted based on a rule-based method, and relationships are extracted using a deep learning method to form a knowledge graph database. Nodes and edges in the knowledge graph are constructed, where nodes are entities and edges are relationships between entities, and the data set is divided into a training set and a test set for training and testing the model. The indicator diagram fault diagnosis prediction is performed based on the knowledge graph and feature extraction results, and the fault type of the indicator diagram data is predicted by a deep learning method. Finally, a model evaluation is performed to determine whether the model is suitable for a specific task, evaluate the performance of the model, and evaluate the model using accuracy, recall, and F1 score.
[0076] A fault diagnosis method for dynamometer diagram based on knowledge graph, the brief process is as follows: Figure 1 As shown, the specific steps include:
[0077] Step 1: Data collection, including obtaining the indicator diagram data of the pumping unit, calculating the maximum load, minimum load and other indicator diagram derived data, and collecting production dynamic data; the specific process is as follows:
[0078] Step 1.1, collect the dynamometer diagram data. The dynamometer diagram is a curve that describes the relationship between load and displacement during the operation of the pumping unit. It reflects the operating status of the pumping unit in a cycle. Obtaining high-quality dynamometer diagram data is the key to ensuring the accuracy of fault diagnosis.
[0079] Step 1.2, calculate the derived data of the indicator diagram based on the indicator diagram data, extract the highest and lowest points of the load from the indicator diagram data, and calculate the maximum load and the minimum load respectively; obtain the average load by averaging all the load data in the indicator diagram; use the differential algorithm to calculate the rate of load change, that is, the load change rate; calculate the time of a complete pumping unit working cycle by detecting the periodic changes of the indicator diagram, that is, the cycle period; use the numerical integration method (such as the trapezoidal integration method) to calculate the area enclosed by the indicator diagram, that is, the indicator diagram area. In addition to the above derived data, other data can also be calculated and analyzed to provide a more comprehensive performance evaluation and optimization of the pumping unit.
[0080] Step 1.3: Systematically collect production dynamic data of other time series and sample data of dynamometer diagram fault types; dynamometer diagram fault types include but are not limited to normal dynamometer diagram, insufficient fluid supply, gas impact, suspected rod breakage, pump collision, sand production, floating valve leakage, etc. Sort the collected data to form a data structure for dynamometer diagram fault diagnosis and build a sample library.
[0081] Step 2: Data preprocessing, including data cleaning, main control factor selection and standardization of the collected data; the specific process is as follows:
[0082] Step 2.1: The collected data is incomplete, noisy, inconsistent, etc. Data cleaning deals with missing values, out-of-bounds values, inconsistencies, duplicate data, etc. from the aspects of data accuracy, completeness, consistency, uniqueness, timeliness, and effectiveness. Data cleaning mainly includes cleaning missing values, filling missing content, and removing unnecessary fields. Generally speaking, missing values are the most common data problem, and there are many ways to deal with missing values. You need to follow the steps. The first step is to determine the range of missing values, calculate the missing value ratio for each field, and then formulate strategies according to the missing ratio and field importance.
[0083] For unnecessary fields, delete them directly. When cleaning data, back up each step, or process the full data after successful experiments on small-scale data. For missing values that need to be filled, there are three general filling methods: filling missing values with business knowledge or experience, filling missing values with the calculation results of the same indicator (mean, median, mode, etc.), and filling missing values with the calculation results of different indicators. In order to ensure the randomness of the data set and the impact on the model, the data is missing, and the null values and zero values in the data set are filled with a smaller random number. The filling process is as follows:
[0084] (1);
[0085] in, Indicates the position in the data set table The value after missing or zero values at are filled, and Respectively represent the rows and columns in the data set table, used to locate specific data points; Indicates the minimum value of filling, which is a very small constant, for example, set to 0.0001; is a random number uniformly drawn from the range [0,1). The purpose of formula (1) is to fill missing values or zero values so that the filled values are close to zero and some randomness is introduced.
[0086] This method is suitable for slightly filling empty values and zero values, so that the filled values are close to zero, and some randomness is introduced to simulate the noise of real data. Data cleaning is an important step in data preprocessing, and its importance lies in ensuring data quality and the effectiveness of model training.
[0087] Step 2.2, based on the feature selection method, filter out the main controlling factors in the collected data, and select samples to build a representative sample library. The collected data are of various types, but not all features are directly related to the fault type of the indicator diagram. In order to improve the accuracy and efficiency of diagnosis, the features are screened. The Spearman correlation coefficient measures the monotonic relationship between two variables. The two variables change at the same time, but not at the same rate, that is, they are not necessarily a linear relationship, and describe nonlinear correlation. The Spearman correlation coefficient does not require the distribution of the original data and is a non-parametric statistical method. The advantage is that it does not require the distribution of the original data, it is a non-parametric statistical method, and it describes nonlinear correlation. The disadvantage is that it has high requirements on the data. The data is usually assumed to come from a normal distribution and is greatly affected by outliers. The formula for the Spearman correlation coefficient is expressed as:
[0088] (2);
[0089] in, is the Spearman rank correlation coefficient, which indicates the correlation between two variables; For two variables in The difference in rank (difference in ranking) among the observations, that is, rank difference between two variables with observations; is the total number of observations, i.e. the number of variable pairs; is the sum of the squares of all rank differences, that is, calculate each , and then add those squared values together.
[0090] There is no clear rule for the classification of correlation strength. Usually, the correlation strength of variables is judged by the following value range:
[0091] (1) When When , the two variables are strongly correlated;
[0092] (2) When When , the two variables are strongly correlated;
[0093] (3) When When , the two variables are moderately correlated;
[0094] (4) When When , the two variables are weakly correlated;
[0095] (5) When When , there is very weak or no correlation between the two variables.
[0096] The Spearman rank correlation coefficient does not require the distribution of the original data and is a non-parametric statistical method. In theory, this method can be used to study the overall distribution of the two variables and the size of the sample size, and it can characterize nonlinear correlation. The Spearman rank correlation coefficient is a non-parametric indicator that measures the dependence of two variables and is often represented by Greek letters. It uses a monotonic equation to evaluate the correlation between two statistical variables without assuming that the two groups of variables follow a normal distribution. If there are no repeated values in the data and when the two variables are completely monotonically correlated, the Spearman correlation coefficient is +1 or -1.
[0097] Correlation analysis evaluates the relationship between each feature and the target variable by calculating the correlation between them, and selects the most relevant and predictive features in the data set, which helps to improve the performance of the model, reduce overfitting and improve the interpretability of the model. At the same time, correlation analysis helps identify features that are strongly correlated with the target variable, thereby performing further feature selection.
[0098] Step 2.3, standardizing the data can not only improve the prediction accuracy, but also for many models, after data standardization, the optimization process of the optimal solution will become smoother, and it is easier to correctly converge to the optimal solution. Since the range of values of different eigenvalues may vary greatly, the numerical value of the feature will directly affect the learning speed and results of the model parameters. By standardizing the data, the dimensional influence between the features is eliminated, the convergence speed of the model is accelerated, and the model performance and generalization ability are improved. Therefore, the filtered data is processed by the minimum-maximum standardization (Min-Max Scaler) to linearly map the original data to the range of [0,1]. The specific expression formula is:
[0099] (3);
[0100] in, Represents the eigenvalue after standardization; The raw data representing the eigenvalues; Represents the minimum value in the eigenvalue data; Indicates the maximum value in the eigenvalue data.
[0101] Step 3: Extract entities, relationships and attributes, construct a knowledge graph, and divide the data set composed of the knowledge graph into a training set and a test set. The present invention extracts entities and attributes based on a rule-based method, uses a deep learning method to extract relationships, forms a knowledge graph database, constructs nodes and edges in the knowledge graph, where nodes are entities and edges are relationships between entities, and divides the data set into a training set and a test set to train and test the model. The specific process is as follows:
[0102] Step 3.1: Entity extraction refers to the automatic identification of named entities from text datasets. The quality of entity extraction (precision and recall) has a great impact on the efficiency and quality of subsequent knowledge acquisition, so it is the most basic and critical part of information extraction.
[0103] There are many types of entity extraction methods. The rule-based method extracts entities from data based on predefined rules and patterns. It is very suitable for processing structured data. Structured data has a fixed format and can quickly and accurately extract the required entities. Compared with other entity extraction methods, the rule-based method is more efficient in processing structured data and does not require a large amount of training data and a complex model training process. In addition, rule-based entity extraction is interpretable. Since the extraction rules and patterns are manually defined, the implementation process can be clearly defined. When processing data in a specific field, specific rules can be set according to domain knowledge and actual needs to improve the relevance and accuracy of the extraction and meet the needs of actual applications.
[0104] It is crucial to choose an appropriate entity extraction method based on the structure of the collected data. Since all collected data is structured data with clear data formats and fields, the rule-based entity extraction method is the most appropriate and effective. It can not only make full use of the structured characteristics of the data and improve the accuracy and efficiency of entity extraction, but also simplify the development process and save time.
[0105] The rule-based method for entity extraction can quickly and accurately extract the required entities from structured data. It mainly includes two entity classes, namely well entity and fault type entity. The unique values of well and fault type are directly extracted from the data as entities. The entity extraction formula is expressed as:
[0106] (4);
[0107] (5);
[0108] In addition, the entity extraction formula can also be expressed as:
[0109] (6);
[0110] in, is the extracted entity set; It is an element in the entity set, which can be an instance of "well" or "fault type"; is the well entity index, Indicates Well entity; is the fault type index, Indicates Fault type entity; It means extracting unique values from the data as all well entities; It means extracting unique values from the data as all fault type entities; Function is used to extract unique values from a dataset; A data frame containing the required data for performing entity extraction and other data analysis tasks; is a data frame containing well data; is a data frame containing the fault type data.
[0111] Step 3.2, the knowledge graph is composed of nodes (entities) and edges (relationships), which are used to represent the relationships between entities in the data. Relationships are crucial in the knowledge graph and are used to describe the association or connection between entities. The existence of relationships can connect scattered entities to form a structured data network, so that the data is no longer an independent point.
[0112] According to the number of samples, data structure and number of entities, deep learning methods are used to extract relations and build a relation extraction model. The relation extraction model adopts a multi-layer graph convolutional neural network model. Through graph convolution operations, high-level feature representations of nodes are extracted to accurately identify the association between wells and fault types. The relation extraction formula is expressed as:
[0113] (7);
[0114] in, is the extracted relation set.
[0115] The structure of the multi-layer graph convolutional neural network model of the present invention is as follows Figure 3 As shown in the figure, it includes an input layer, a convolutional layer, a pooling layer, a fully connected layer, and an output layer connected in sequence. The convolutional layer contains 3 convolutional modules and a linear layer. The hierarchical structure of a multi-layer graph convolutional neural network, including the type of each convolutional module, the input feature dimension, the output feature dimension, and the activation function. After the convolutional layer, the pooling layer is used to reduce the spatial size of the feature map, thereby reducing the number of parameters and the amount of calculation, while making feature detection more robust. After the convolutional layer and the pooling layer extract features, the fully connected layer is used to process these features for the final relationship extraction.
[0116] Step 3.3, attribute extraction is mainly for entities, and attributes can form a complete outline of entities. Since the attributes of an entity can be regarded as a nominal relationship between the entity and the attribute value, the problem of extracting entity attributes can be converted into a relationship extraction problem. The goal of attribute extraction is to identify and extract the attributes of an entity from the data. According to the collected data, except for the entity, the rest of the data is regarded as attributes. Attribute extraction also uses a rule-based method to directly extract attributes and attribute values from the data.
[0117] The rule-based method can quickly identify and extract the required attributes and attribute values. At the same time, the rule-based method is simple and direct, and can quickly and effectively extract entities, relationships, and attributes from the data. The attribute extraction formula is expressed as:
[0118] (8);
[0119] in, is the set of extracted attributes; Indicates properties, It is the index or identifier of the attribute, used to distinguish different attributes; Indicates Well Entity No. Attributes The value of For data frame Middle Well Entity and Attributes Specific attribute value of To access an attribute in a data frame, Indicates that the well entity is indexed and Attributes To locate the specific attribute value, the well entity index and Attributes As The column index and column tag of the .
[0120] Step 3.4: Entities, relationships and attributes are obtained by performing entity extraction, relationship extraction and attribute extraction from structured data. The relationship connects the well entity and the fault type entity, describes the connection between the well and the fault, and then uses a graph structure to represent the relationship between entities, finally forming knowledge graph data.
[0121] The extracted entities, relationships and attributes are used to construct a knowledge graph. The knowledge graph is a graph structure. Each node in the knowledge graph represents a well entity or a fault type entity. Each edge represents the relationship between the well entity and the fault type entity. The node features represent the attributes of the entity. The graph structure formula is as follows:
[0122] (9);
[0123] in, Representation diagram; Represents entity nodes, used to represent entities; Represents the extracted relation set.
[0124] The information in the knowledge graph is fused in the node feature matrix. These features include attribute features and category labels extracted from the knowledge graph. As additional feature dimensions of the node, these fused features are used to update the representation of the node, thereby enhancing the effect of relationship extraction. Specifically:
[0125] In the knowledge graph, the adjacency matrix is used to represent the structure of the graph, and the node feature matrix represents the features of each node, which are expressed as follows:
[0126] (10);
[0127] in, Represents the adjacency matrix, which is used to express the relationship between nodes in the graph.
[0128] (11);
[0129] in, Represents the node feature matrix, which is used to express the attribute characteristics of each node; is the node feature matrix Line The eigenvalues corresponding to the columns. In the node feature matrix It not only contains the original data features, but also the attribute feature category labels extracted from the knowledge graph as additional feature dimensions of the node.
[0130] Step 3.5: In order to conduct the model training and evaluation process more scientifically and accurately, the data set composed of the knowledge graph is divided into a training set and a test set. Dividing the data set can establish a scientific evaluation framework during the model development process to ensure that the model not only performs well on the training data, but also maintains efficient and accurate prediction capabilities in practical applications, and more accurately understands the performance of the model on unseen data to avoid overfitting or underfitting.
[0131] Step 4: Build a graph attention network model for dynamometer fault diagnosis and train the model. The specific process is as follows:
[0132] Step 4.1: In the prediction of fault type of dynamometer diagram, a graph attention network model with embedded global auxiliary relations is constructed, such as Figure 4As shown in the figure, the graph attention network model mainly consists of three parts: entity encoder, relation encoder and decoder. The entity encoder is implemented based on the CompGCN (multi-relation heterogeneous graph neural network) framework, and dynamically adjusts the aggregation ratio of the central node in combination with the attention mechanism (that is, using the attention mechanism for aggregation update), and uses the ReLU function for nonlinear activation; the relation encoder mainly focuses on improving the representation of relation embedding, and the dot product operation is used in the relation encoder to evaluate the relationship The similarity between entities and other relations is converted into an attention score through a fully connected layer, and finally the attention score in the attention mechanism is normalized using the Softmax function to finally obtain the attention weight of the relation; the decoder is used to verify the effectiveness of the network. In the decoder, the ConvE model is used to reshape the embedding vectors of entities and relations into a two-dimensional tensor, and the reshaped two-dimensional tensor is convolved by the convolutional neural network to extract the local features of the triples, and finally the pooling layer is used to reduce the dimension of the feature space, and finally the output features of the decoder are mapped to the category space and output. The advantages of the relations in the knowledge graph are used to enhance the prediction ability of the model, and the ability of the graph attention neural network model to analyze and model graph structure data is fully utilized to effectively extract complex relations from the data and achieve accurate fault diagnosis prediction.
[0133] In the entity encoder, based on the CompGCN framework, the influence of different relations in the directed knowledge graph is considered, and the message function is used to pass messages and integrate the process of neighbor entity and relation embedding. For a given triple , the aggregation of neighbor entities and relationship embeddings of the central node can be done using the message function To express, in the CompGCN framework, the embedding vectors of neighbor entities and relations are combined using multiplication operations; the aggregation ratio of each neighbor node is dynamically adjusted using the attention mechanism. The attention function uses dot products to measure the similarity between embedding vectors, and adjusts the calculation process of the attention function through a learnable vector; after aggregating the neighbor node information, the nonlinear activation function ReLU is used to introduce nonlinearity. Among them, is the head entity, representing a node in the knowledge graph, and is a relation Starting point; For the relationship, it represents the head entity and tail entity the relationship between; is the tail entity, representing another node in the knowledge graph, which is a relationship The end point.
[0134] In the relation encoder, a relation is defined as a basis vector that represents the "direction" of the relation in the relation space, and an attention mechanism is also used to identify and aggregate strongly related neighboring relations. , using the dot product operation to evaluate The similarity between other relations is converted into an attention score through a fully connected layer, and finally the Softmax function is used to normalize the attention score in the attention mechanism to obtain the attention weight of the relation.
[0135] In the decoder, the ConvE (convolutional embedding) model is used to reshape the embedding vectors of entities and relations into two-dimensional tensors. The reshaped two-dimensional tensors are convolved by a convolutional neural network to extract the local features of the triples, and finally a pooling layer is used to reduce the dimension of the feature space.
[0136] The output features of the decoder are mapped to the category space, and the prediction formula of the output dynamometer fault diagnosis is as follows:
[0137] (12);
[0138] in, represents the weight matrix; represents the bias vector; represents the input feature vector; Represents the output vector.
[0139] The fully connected layer maps the features of the last layer in the graph convolutional network to the category space. It takes the input feature vector With the weight matrix Multiply and add bias , and then undergo a nonlinear transformation to get the output.
[0140] Step 4.2: During model training, the cross-entropy loss function is used to calculate the loss between the model's predicted output and the true label. The formula is as follows:
[0141] (13);
[0142] in, is the value of the loss function; is the total number of samples, that is, the number of samples in the data set; is the index of the current tag; Indicates The actual value of the label; Indicates The predicted value of the label.
[0143] The Adam optimizer is used to update the model parameters during the gradient descent process. Adam is an adaptive learning rate optimization algorithm that combines momentum gradient descent and adaptive learning rate adjustment. It adaptively adjusts the learning rate of each parameter by maintaining the first-order moment estimate and the second-order moment estimate of each parameter. The formula is as follows:
[0144] (14);
[0145] in, Represents the time step The parameter value at that time, that is, the parameter after one update; Represents the time step , that is, the parameter value before this update; represents the learning rate; Represents the time step Momentum at time Represents the time step The first moment estimate when ; represents a small constant used for numerical stability.
[0146] Step 5: Use accuracy, recall, and F1 score to comprehensively evaluate the graph attention network model based on the training set and test set to fully identify sample faults and reduce false positives and negatives. The specific process is as follows:
[0147] Step 5.1, accuracy refers to how many correct judgments are made among all the judgments, that is, how many positive judgments are made as positive and how many negative judgments are made as negative. The accuracy formula is:
[0148] (15);
[0149] in, is the accuracy value; True Positive means that if an instance is a positive class, it is predicted to be a positive class; True Negative, which means that if an instance is a negative class, it is predicted to be a negative class; False Positive means that if an instance is a negative class, it is predicted to be a positive class; It is a false negative class, which means that if an instance is a positive class, it is predicted to be a negative class.
[0150] The accuracy reflects the overall classification effect of the model and can measure the performance of the model on all samples. A higher accuracy means that the model can better identify faults and normal states, which helps to reduce false positives and false negatives.
[0151] Step 5.2, recall is relative to the sample, that is, how many positive samples in the sample are predicted correctly, and the number of positive samples is samples, all positive samples have two destinations, one is judged as positive, and the other is wrongly judged as negative. The recall formula is expressed as:
[0152] (16);
[0153] in, is the recall value;
[0154] The recall rate indicator mainly measures the model's ability to identify positive samples. A high recall rate indicates that the model has identified most fault samples, which can reduce missed reports and ensure that faults are discovered and handled in a timely manner.
[0155] Step 5.3, F1 score is an indicator used in statistics to measure the accuracy of binary classification (or multi-task binary classification) models, also known as balanced F1 score (Balanced Score). It takes into account both the precision and recall of the classification model, and can be regarded as a weighted average of the precision and recall of the model. Its maximum value is 1 and the minimum value is 0. The larger the value, the better the model. The F1 score formula is expressed as:
[0156] (17);
[0157] in, is the F1 score value; is the precision value, which indicates the proportion of samples whose predicted value is 1 and whose true value is also 1 to all samples whose predicted value is 1. The precision formula is:
[0158] (18);
[0159] The F1 score takes into account both precision and recall, and is an evaluation of the overall performance of the model. A higher F1 score value indicates that the model can not only identify most faults (high recall), but also reduce false positives (high precision), which is a comprehensive evaluation of the model performance.
[0160] In order to demonstrate the feasibility and superiority of the present invention, the following examples are given.
[0161] This example is based on the field data of an oil field, with a total of 28,934 pieces of dynamometer working condition data. The specific process is as follows:
[0162] According to the above step 1, data is collected, and the obtained dynamometer data includes power characteristic data such as dynamometer area and dynamometer curve, which are used to reflect the electric power output of the oil pump under different working conditions; the derived data is obtained by analyzing and calculating the dynamometer data, and mainly includes floating valve closing distance, floating valve opening distance, fixed valve closing distance, fixed valve opening distance, upstroke slope 1, upstroke slope 2, downstroke slope 1, downstroke slope 2, downstroke effective stroke, filling degree, downstroke average load, upstroke average load, maximum load, minimum load, theoretical load, theoretical download, rod column weight, liquid column weight, pump friction load, calculated displacement, calculated daily liquid production, theoretical displacement, maximum area of dynamometer, calculated dynamic liquid level, suspension point motion intercept, suspension point motion angle, suspension point motion law, no The data of effective stroke, pump effective stroke, rod and tube stretching efficiency, bare rod power, calculated pump efficiency, upper stroke slope of pump power diagram, upper stroke angle of pump power diagram, upper stroke intercept of pump power diagram, lower stroke slope of pump power diagram, lower stroke angle of pump power diagram, lower stroke intercept of pump power diagram, and upper stroke effective stroke are used to comprehensively evaluate the operation and performance of the oil pumping unit; the production dynamic data such as stroke, stroke, oil pressure, casing pressure, back pressure, wellhead temperature, voltage a, voltage b, voltage c, current a, current b, current c, power factor, average active power, maximum active power, minimum active power, average reactive power, upward current, downward current, daily liquid production, daily oil production, daily water production, daily gas production, water content, gas-oil ratio, pump diameter, pump depth, pump efficiency, dynamic liquid level, etc. reflect the dynamic changes in the working process of the oil pumping unit, which is helpful for in-depth analysis and diagnosis of the working condition of the oil pumping unit.
[0163] The main fault types of the dynamometer diagram are: normal dynamometer diagram, insufficient fluid supply, gas influence, suspected rod breakage, fixed valve leakage, pump collision, upper piston leakage, sand production, floating valve leakage, lower piston leakage, etc.
[0164] Perform data preprocessing according to step 2 above. Since the collected data has many missing values and zero values, these missing data will affect the training effect of the model and the accuracy of prediction. In order to ensure the randomness of the data set and the impact on the model, the data is processed for missing values, and the empty values and zero values in the data set are filled with a smaller random number. First, determine the location of the empty values and zero values in the data set, and then generate a small random number between 0 and 0.01 to fill the empty values and zero values. This can ensure the integrity of the data and introduce a certain degree of randomness to avoid excessive deviation in the model results.
[0165] Based on the feature selection method, the main controlling factors in the collected data are determined, and the Spearman correlation coefficient method is used to screen out the most relevant and predictive features, which helps to improve the performance of the model, reduce overfitting and improve the interpretability of the model. Calculate the Spearman correlation coefficient between each feature and the fault type, sort the features according to the absolute value of the correlation coefficient calculation result, select the features with higher correlation as the input features of the model, discard the features with lower correlation, reduce the number of features, and improve the predictive performance of the model. The correlation coefficient results screen the top 16 features, mainly including the indicator diagram area, floating valve closing distance, floating valve opening distance, fixed valve closing distance, fixed valve opening distance, downstroke effective stroke, filling degree, upstroke slope 1, upstroke slope 2, downstroke slope 1, downstroke slope 2, oil pressure, casing pressure, upcurrent, downcurrent, stroke, and the correlation coefficient results are as follows: Figure 5 shown.
[0166] The filtered feature data is processed by Min-Max Scaler to linearly map the original data to the range of [0,1]. First, the maximum and minimum values of the feature are calculated, and the feature values are standardized using formula (3) to eliminate the dimensional differences between the features, so that the model can better learn the relationship between the features during the training process and improve the training and prediction effects of the model.
[0167] According to the above step 3, a knowledge graph database is constructed, and the data set composed of the knowledge graph is divided into a training set and a test set for model training and testing. The data structure of the data set includes well name, acquisition time, dynamometer area, oil pressure, filling degree, dynamometer area, downstroke effective stroke, fault type, etc.;
[0168] In the present invention, there are two types of entities, namely wells and fault types. According to the number of samples, data structure and number of entities, a deep learning method is used to extract relationships and a multi-layer graph convolutional neural network is constructed. Through graph convolution operations, high-level feature representations of nodes are extracted to accurately identify the association between wells and fault types.
[0169] The specific structure of the multi-layer graph convolutional neural network of the present invention is set as follows: the first convolution module (GCNConv (Conv1)) has an input feature dimension of the number of node features, an output feature dimension of 16, and an activation function of ReLU; the second convolution module (GCNConv (Conv2)) has an input feature dimension of 16, an output feature dimension of 32, and an activation function of ReLU; the third convolution module (GCNConv (Conv3)) has an input feature dimension of 32, an output feature dimension of 64, and an activation function of ReLU; the linear layer (Linear (linear)) has an input feature dimension of 64, an output feature dimension of 1, and no activation function.
[0170] The data set has a clear data format and fields. The rule-based method can quickly identify and extract the required attributes and attribute values. At the same time, the rule-based method is simple and direct, and can quickly and effectively extract entities, relationships and attributes from the data. The features selected by the main control factors are all used as attributes, mainly including the indicator diagram area, floating valve closing distance, floating valve opening distance, fixed valve closing distance, fixed valve opening distance, downstroke effective stroke, filling degree, upstroke slope 1, upstroke slope 2, downstroke slope 1, downstroke slope 2, oil pressure, casing pressure, upcurrent, downcurrent, stroke.
[0171] Entities, relations and attributes are obtained by performing entity extraction, relation extraction and attribute extraction from structured data. The relation connects the well entity and the fault type entity, describing the connection between the well and the fault. Then, the graph structure is used to represent the relationship between the entities, and finally the knowledge graph data is formed. The data structure is as follows: Figure 2 The extracted data structure is shown in Table 1. Due to the huge amount of data, Figure 2 Only some entities, some attributes and the relationships between them in the entire knowledge graph data are shown in Figure 1, and only the data structure after partial information extraction of 5 wells is shown in Table 1.
[0172] Table 1 Description of some data structures after information extraction
[0173] .
[0174] The extracted entities, relationships and attributes are used to construct a knowledge graph. Based on the graph structure, the well entity and fault type entity in the knowledge graph are used as nodes, and the relationship between the well and fault type entities is used as edges to form a graph data structure. Each node represents an entity, and each edge represents the relationship between entities. The node features represent the attributes of the entities. The entity nodes in the graph include well entities and fault entities, and the edges in the graph are the relationships between well entities and fault entities.
[0175] Dividing the dataset into 80% training set and 20% test set can establish a scientific evaluation framework during the model development process to ensure that the model not only performs well on the training data but also avoids overfitting or underfitting.
[0176] According to the above step 4, predict the fault type of the indicator diagram data; the model structure in the present invention consists of an entity encoder, a relation encoder and a decoder, the entity set is used as the input of the entity encoder, the relation set is used as the input of the relation encoder, and the knowledge graph is used as the basis. The entity encoder is based on the CompGCN framework, introduces an attention mechanism to dynamically adjust the aggregation ratio, and uses the ReLU function to introduce nonlinear activation to improve the training efficiency and expression ability of the model. In the relation encoder, the relation set is input into the fully connected network. The attention mechanism calculates the similarity from the perspective of the embedding of the relation and the vector domain to which the relation belongs. The learnable Softmax (L-Softmax) is used to standardize the attention value instead of the conventional Softmax. Set a learnable scalar so that the model can adaptively amplify the importance of similar nodes and ignore the influence of different nodes in the normalization process. The ConvE model is used in the decoder to verify the effectiveness of the network. ConvE is one of the most commonly used decoders in triple prediction. ConvE uses convolution and fully connected layers to model input entities and relationship embeddings.
[0177] In each training cycle (epoch) of the graph attention network model, the model is set to training mode, and features such as dropout and batch normalization are used to enhance the generalization ability of the model; the training data is passed into the model, and the predicted output of the model is calculated through forward propagation; based on the difference between the predicted output and the true label, the cross entropy loss function is used to calculate the loss value; the gradient of the loss relative to the model parameters is calculated through the backpropagation algorithm to guide the update of the model parameters, and the parameters are adjusted using the Adam optimizer to minimize the loss function. The entire training process is carried out for 300 iterations (epochs), and the model parameters are updated once in each cycle. In order to evaluate the performance of the model, the loss curves on the training set and the test set are recorded and plotted, and their changing trends are analyzed to understand the fitting effect and generalization ability of the model on the training data and unseen data. The loss curve of the model result is shown in the figure below. Figure 6 shown.
[0178] Follow step 5 above to evaluate the model performance. Define a comprehensive evaluation function to calculate multiple performance indicators on the training set and test set, including loss value, accuracy, recall rate, and F1 score. This evaluation function will evaluate the training set and test set separately after each training cycle (epoch). In order to effectively monitor the training process of the model and its performance changes, use Matplotlib to draw charts. These charts include accuracy, recall, and F1 score on the training set and test set. 1 The trend of the score changing with the training cycle. The accuracy comparison results of the model training set and test set are as follows Figure 7 As shown; the comparison results of the recall rate of the model training set and test set are shown in Figure 8 As shown; the comparison results of F1 scores of model training set and test set are as follows Fig. 9 Based on these visualization results, we can analyze the performance changes of the model during the training process, determine whether the model has overfitting or underfitting problems, and adjust the model parameters accordingly.
[0179] Of course, the above description is not a limitation of the present invention, and the present invention is not limited to the above examples. Changes, modifications, additions or substitutions made by technicians in this technical field within the essential scope of the present invention should also fall within the protection scope of the present invention.
Claims
1. A method for fault diagnosis of dynamometer diagram based on knowledge graph, characterized in that: The following steps are included: Step 1: collect data, including obtaining the indicator diagram data of the pumping unit, calculating the derived data of the indicator diagram, and collecting production dynamic data; Step 2: Data preprocessing, including data cleaning, main control factor selection and standardization of the collected data; Step 3: Extract entities, relationships, and attributes, construct a knowledge graph, and divide the dataset consisting of the knowledge graph into a training set and a test set. The specific process is as follows: Step 3.1: The rule-based method directly extracts the unique values of well and fault type from the data as entities, and extracts two entity classes, namely well entity and fault type entity; the entity extraction formula is expressed as: E = {e i , e j | e i ∈ unique(df['井']), e j ∈ unique(df['故障类型'])}; Among them, E is the extracted entity set; i is the well entity index, e i represents the i-th well entity; j is the fault type index, e j represents the jth fault type entity; unique(df[′well′]) represents extracting unique values from the data as all well entities; unique(df[′fault type′]) represents extracting unique values from the data as all fault type entities; the unique(·) function is used to extract unique values from a data set; df is a data frame containing the required data; df[′well′] is a data frame containing well data; df[′fault type′] is a data frame containing fault type data; Step 3.2: Based on the number of samples, data structure, and number of entities, use deep learning methods to extract relations. The relation extraction formula is expressed as: R = {(e i , 'production status relationship', e j ) | e i ∈ df['well'], e j ∈ df['fault type']}; Among them, R is the extracted relationship set; Step 3.3: Attribute extraction also uses a rule-based approach to directly extract attributes and attribute values from the data; the attribute extraction formula is expressed as: A = {(e i , a k , v ik ) | e i ∈ df['井'], e j ∈ df['故障类型'], a k ∈ 属性, v ik = df.at[i, a k}; Among them, A is the extracted attribute set; a k Indicates the kth attribute, where k is the index or identifier of the attribute, used to distinguish different attributes; v ik Represents the i-th well entity e i The kth attribute a k The value of df.at[i,a k ] is the i-th well entity e in the data frame df i and the kth attribute a k The specific attribute value of at is to access an attribute in the data frame, [i,a k ] indicates that the well entity index i and the kth attribute a k To locate the specific attribute value, where the well entity index i and the kth attribute a k As [i, a k ]'s column index and column identifier; Step 3.4: Use the extracted entities, relationships, and attributes to construct a knowledge graph. The knowledge graph is a graph structure. Each node in the knowledge graph represents a well entity or a fault type entity. Each edge represents the relationship between the well entity and the fault type entity. The node features represent the attributes of the entity. The graph structure formula is as follows: G = (V, R); Among them, G represents a graph; V represents an entity node; R represents the extracted relationship set; Step 3.5: Divide the data set consisting of the knowledge graph into a training set and a test set; In the knowledge graph constructed in step 3.4, the adjacency matrix is used to represent the structure of the graph, and the node feature matrix represents the features of each node, which are respectively expressed as follows: in, Represents the adjacency matrix, which is used to express the relationship between nodes in the graph; Among them, X represents the node feature matrix, which is used to express the attribute characteristics of each node; is the node feature matrix Line The eigenvalues corresponding to the columns; Step 4: Build a graph attention network model for dynamometer fault diagnosis and train the model. The specific process is as follows: Step 4.1: Build a graph attention network model, which consists of three parts: entity encoder, relation encoder and decoder. Step 4.2: During model training, use the cross entropy loss function to calculate the loss between the model's predicted output and the true label. In the entity encoder of the graph attention network model, the influence of different relations in the directed knowledge graph is considered based on the multi-relation heterogeneous graph neural network framework, and the message function is used to pass messages and integrate the neighbor entity and relationship embedding process. For a given triple (h, r, t), the aggregation of the neighbor entity and relationship embedding of the central node uses the message function To represent, in the multi-relation heterogeneous graph neural network framework, the embedding vectors of neighbor entities and relations are combined using multiplication operations; the aggregation ratio of each neighbor node is dynamically adjusted using the attention mechanism, the attention function uses dot product to measure the similarity between the embedding vectors, and adjusts the calculation process of the attention function through a learnable vector; after aggregating the neighbor node information, the nonlinear activation function ReLU is used to introduce nonlinearity; where h is the head entity; r is the relation; t is the tail entity; In the relation encoder, a relation is defined as a basis vector, which represents the "direction" of the relation in the relation space. At the same time, the attention mechanism is used to identify and aggregate strongly correlated neighboring relations. For relation r, the dot product operation is used to evaluate the similarity between r and other relations. The similarity is converted into an attention score through a fully connected layer. Finally, the Softmax function is used to normalize the attention score in the attention mechanism to obtain the attention weight of the relation. In the decoder, a convolutional embedding model is used to reshape the embedding vectors of entities and relations into two-dimensional tensors. A convolutional neural network is used to perform convolution operations on the reshaped two-dimensional tensors to extract local features of triples. Finally, a pooling layer is used to reduce the dimension of the feature space. The output features of the decoder are mapped to the category space, and the prediction results of the dynamometer fault diagnosis are output. The formula is as follows: Where W represents the weight matrix; b represents the bias vector; represents the input feature vector; represents the output vector; In step 4.2, the cross entropy loss function formula is as follows: Among them, Loss is the value of the loss function; N is the total number of samples, that is, the number of samples in the data set; c is the index of the current label; y c Represents the actual value of the cth label; Represents the predicted value of the cth label; The Adam optimizer is used to update the model parameters during the gradient descent process. Adam is an adaptive learning rate optimization algorithm that combines momentum gradient descent and adaptive learning rate adjustment. The formula is as follows: Among them, θ s+1 represents the parameter value at time step s+1, that is, the parameter after one update; θ s represents the parameter value at time step s, that is, the parameter before this update; η represents the learning rate; v s represents the momentum at time step s; m s represents the first-order moment estimate at time step s; ∈ represents a small constant for numerical stability; Step 5: Use accuracy, recall, and F1 score to comprehensively evaluate the graph attention network model based on the training set and test set.
2. The method for diagnosing faults in a dynamometer diagram based on knowledge graph according to claim 1, characterized in that: The specific process of step 1 is as follows: Step 1.1, collect the data of the indicator diagram, which is a curve describing the relationship between load and displacement during the operation of the pumping unit; Step 1.2, calculate the derived data of the indicator diagram according to the indicator diagram data, extract the highest point and the lowest point of the load from the indicator diagram data, and calculate the maximum load and the minimum load respectively; obtain the average load by averaging all the load data in the indicator diagram; The rate of load change is calculated using a differential algorithm to obtain the load change rate; By detecting the periodic changes of the indicator diagram, the time of a complete pumping unit working cycle is calculated to obtain the cycle period; the area enclosed by the indicator diagram is calculated using the numerical integration method to obtain the indicator diagram area; Step 1.3, collect production dynamic data of other time series and sample data of dynamometer diagram fault types; dynamometer diagram fault types include normal dynamometer diagram, insufficient liquid supply, gas influence, suspected rod breakage, pump collision, sand production, and floating valve leakage; organize the collected data to form a data structure for dynamometer diagram fault diagnosis and build a sample library.
3. The method for diagnosing faults in a dynamometer diagram based on knowledge graph according to claim 1, characterized in that: The specific process of step 2 is as follows: Step 2.1: Data cleaning includes cleaning missing values, filling missing contents, and removing unnecessary fields. The filling process is as follows: dataFill (p,q) =num×data random ; Among them, dataFill (p,q) Indicates the value after the missing value or zero value at position (p, q) in the data set table is filled. p and q represent the row and column in the data set table respectively. num represents the minimum value to be filled. data random is a random number uniformly drawn from the range [0,1); Step 2.2: Based on the feature selection method, the main controlling factors in the collected data are screened. Specifically, the Spearman correlation coefficient is used to screen the features. The formula is: Among them, ρ is the Spearman rank correlation coefficient, which represents the correlation between two variables; For two variables in The rank difference among observations; n is the total number of observations; is the sum of the squares of all rank differences; Step 2.3: Apply minimum-maximum normalization to the filtered data to linearly map the original data to the range of [0,1]. The specific formula is: Among them, x′ represents the eigenvalue after standardization; Represents the original data of the eigenvalue; min(·) represents the minimum value in the eigenvalue data; max(·) represents the maximum value in the eigenvalue data.
Citation Information
Patent Citations
Mechanical fault diagnosis method based on knowledge graph and graph neural network
CN113283027A
Oil pumping unit indicator diagram fault diagnosis method based on deep learning
CN117094370A
