A heartbeat anomaly detection method based on semi-supervised graph contrastive learning
Through the method based on semi-supervised graph comparison learning, a state diagram of heartbeat time series data is constructed and graph representation comparison learning is performed, which solves the problems of high computing cost and poor scalability in the prior art, and achieves efficient abnormal detection effect.
Patent Information
- Application Number
- CN202210789455.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-06
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2042-07-06
AI Technical Summary
The prior art has problems such as high computational cost, poor scalability and inability to effectively handle intermittent tags in the abnormal detection of heartbeat time series data.
Using a method based on semi-supervised graph comparison learning, a state graph of heartbeat time series data is constructed, a balanced graph comparison learning sample is constructed, and a binding graph representation comparison learning is performed. Finally, the classifier is trained to perform abnormal detection.
It improves the effect of heartbeat time series data abnormal detection, reduces calculation costs, enhances the scalability of data sets with large samples and long time series, and effectively deals with the problem of lack of labels.
Smart Images

Figure QLYQS_3 
Figure QLYQS_4 
Figure QLYQS_5
Abstract
Description
Technical Field
[0001] The present invention relates to the field of abnormal heartbeat detection, and in particular to a method for abnormal heartbeat detection based on semi-supervised graph contrast learning. Background Art
[0002] Heartbeat time series data is a set of observations of human heartbeat sounds recorded in time. Accurate and real-time detection of heartbeat changes in patients with heart disease is crucial to the health of patients. Traditional time series data classification methods such as HIVE-COTE and TS-CHIEF are complex, computationally expensive, and cannot benefit from GPU hardware. They also have poor scalability for data sets with many samples and long time series. Some methods based on recurrent neural networks take a long time to train and have low accuracy. They cannot handle sequences where labels are intermittent. Summary of the invention
[0003] The purpose of the present invention is to improve the effect of abnormality detection of heartbeat time series data.
[0004] The technical solution of the present invention is as follows:
[0005] The present invention discloses a heartbeat anomaly detection method based on semi-supervised graph contrast learning, comprising the following steps: (1) constructing a state graph of heartbeat time series data; (2) constructing a balanced graph contrast learning sample; (3) performing constrained graph representation contrast learning on paired graphs; and (4) training a classifier.
[0006] The technical solution provided by the present invention is: a heartbeat anomaly detection method based on semi-supervised graph contrast learning, comprising the following steps:
[0007] Step 1: Constructing a state diagram for heartbeat time series data
[0008] The number of nodes in the state diagram is determined by the number of sub-Gaussians in the mixed Gaussian model, which is used as the hyperparameter n in the model. state , and the initialization attribute characteristics of the state diagram are obtained by concatenating the mean and variance of each Gaussian row by row, through the following steps:
[0009] S1: For the heartbeat time series sample s i ∈R n×m , cut each heartbeat time series sample into s i ={s ia1 ,s ia2 ,…,s iaj}, where a=a1=a2=a j represents the split size in the sample;
[0010] S2: Set a suitable hyperparameter nstate , that is, the number of sub-Gaussians is the number of nodes in the state diagram, for the newly divided Fit the Gaussian mixture model to obtain a trained Gaussian mixture model;
[0011] S3: In order to measure the change law within each heartbeat time series subsequence sample and calculate the transfer matrix, the heartbeat time series subsequence sample is divided into two sections, namely, the front section includes {a1, a2, …, a j-1}, the latter part includes {a2,a3,…,a j}, the posterior probability of each sample of the heartbeat time series is calculated by the trained Gaussian mixture model. The posterior probability is The probability distribution of each small block in ;
[0012] S4: According to the formula Calculate the transfer matrix The transfer matrix is the constructed state graph, where v represents a state of each node in the graph, t is a certain moment, and X t is the time series segment, θ v is the state mode, P(θ v |X t-1 ) is the heartbeat time series segment X t The posterior probability of which state mode it belongs to. Each edge represents the transition relationship of the heartbeat data from v to v′. This transition relationship is the state diagram of the heartbeat time series data. i} state evolution diagram, marked as {G i}, the state evolution diagram of the heartbeat time series with existing labels is denoted as {G L}, the unlabeled heartbeat time series state evolution diagram is denoted as {G U};
[0013] Step 2: Construct a balanced graph comparison learning sample
[0014] For any state graph mt i Flatten the matrix into a vector and calculate mt i With mt i+1 After multiplying the vectors and dividing by the modulus, we get Calculate similarity, where i=1,2,..., represents the number of state diagrams, which is also the number of heartbeat time series samples. Calculate the pairwise similarity between samples according to the time axis of the heartbeat time series and mark the similarity and dissimilarity. Here, if the cos similarity is greater than 0.5, it means that the paired graph samples are similar, that is, marked as 1; if the cos similarity is less than 0.5, it means that the paired graph samples are dissimilar, that is, marked as -1;
[0015] Step 3: Perform constrained graph representation comparative learning on paired graphs
[0016] After doing Fourier transform on the graph, we can get the approximate convolution formula of the graph Where D is the degree matrix, A is the adjacency matrix, H (l) is the node representation, W (l) is a learnable parameter, and according to this formula, the neural network can be trained directly through the following steps:
[0017] S1: All constructed graphs G i All of them pass through the graph neural network. In the last layer of the graph neural network, a maximum pooling layer is used, that is, the node representation of the graph is converted into a vector representation of the graph by selecting the maximum value of each node representation. A linear layer is added to the graph representation to convert the output of the graph neural network output into Where C represents the number of categories;
[0018] S2: For each graph G i The vector representation of the empirical distribution f is obtained through the softmax function θ (G i ), where the empirical distribution is defined as: Where N is the number of subsequences divided in the heartbeat time series sample;
[0019] S3: Calculate the KL divergence for the average empirical distribution of the paired P = (G1, G2). The loss function used in the present invention is constructed by applying a hinge loss on the KL divergence, specifically: Where ρ is the marginal parameter of hinge loss, P S Represents similar graph pairs, P D Represents dissimilar pairs of images;
[0020] S4: The GCN network is trained according to this loss function: Where P L represents a labeled image pair, P U represents an unlabeled graph pair, λ R It is a fine-tunable parameter, usually ranging from 0 to 1, in order to constrain the balance between labeled samples and unlabeled samples in the entire batch;
[0021] Step 4: Train the classifier
[0022] For the input state diagram G i After the graph neural network f θ The obtained representation is then subjected to the maximum pooling to obtain the graph vector representation, which can be used as a classifier network f ψThe training classifier is trained through the following steps: S1: A 2-layer feedforward neural network is used followed by a softmax function to obtain the distribution of different categories. The labeled and unlabeled graphs (corresponding to the generated Gaussian state graph pairs) can be input into the classification network f ψ S2: Since the learned representation encourages unlabeled data points to gather around labeled data points, entropy regularization is used to utilize unlabeled data by encouraging the classifier boundary to pass through low-density areas. The current training data is composed of G L and G U Two sets, G L Each element in contains a pair (Z i ; Y i ), where Z i It represents the state diagram G i Vector representation obtained through graph neural network Y i For the heartbeat time series s i One-hot encoded labels ( C is the number of categories), G U Each element in is constructed through a Gaussian state diagram (i.e., the set P U (sample in );
[0023] S3: The loss function of the classifier network f is: where λ C is a fine-tunable parameter. represents the cross entropy loss, is the negative cross entropy loss, C is the number of categories, f θ represents the output of a feedforward classification network, which ends up with a softmax distribution, f ψ The input is through the network f θ The learned representation, for unlabeled data, the negative cross entropy loss function encourages the classification network f ψ Producing a lower entropy empirical class distribution, which encourages unlabeled data to be mapped to a single-class distribution, promoting f ψ The classification boundary is moved to a low-density area.
[0024] Aiming at the problem of label scarcity in the task of heartbeat time series classification, a semi-supervised classification method based on graph representation contrastive learning is proposed. This method constructs a state evolution graph by identifying the state of heartbeat time series samples, constructs contrast samples for unlabeled data based on the structural similarity of the state evolution graph, and then performs graph contrastive learning on the evolution graph. By training the contrastive learning network and the classification network, anomaly detection of unlabeled heartbeat time series data is achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 The overall flow chart of the present invention includes constructing a state diagram of heartbeat time series data; constructing a balanced graph comparison learning sample; performing constrained graph representation comparison learning on paired graphs; and training a classifier. DETAILED DESCRIPTION
[0026] Heartbeat time series data comes from the PhysioNet / CinC Challenge 2016. Heartbeat sound recordings are collected from a number of contributors around the world in clinical or non-clinical settings, including healthy subjects and pathological patients. These heartbeat sounds are divided into two categories: normal and abnormal. Normal recordings are from healthy subjects, and abnormal recordings are from patients diagnosed with heart disease. Patients suffer from various diseases, but typical ones are patients with heart valve defects and coronary artery disease. Each recording is truncated to 5 seconds, and then a spectrogram of each instance is created with a window size of 0.061 seconds and an overlap rate of 70%, including 204 training sets, 205 test sets, 61 dimensions, and 405 sample lengths. Due to the high cost of label data collection, label data is extremely scarce. Applying semi-supervised or unsupervised learning to analyze heartbeat time series data is the best choice. In response to the problem of label scarcity in heartbeat time series classification tasks, a heartbeat anomaly detection method based on semi-supervised graph contrast learning is proposed, which includes the following steps:
[0027] Step 1: Constructing a state diagram for heartbeat time series data
[0028] The number of nodes in the state diagram is determined by the number of sub-Gaussians in the mixed Gaussian model, which is used as the hyperparameter n in the model. state , and the initialization attribute characteristics of the state diagram are obtained by concatenating the mean and variance of each Gaussian row by row, through the following steps:
[0029] S1: For the heartbeat time series sample s i ∈R n×m , cut each heartbeat time series sample into s i ={s ia1 ,s ia2 ,…,s iaj}, where a=a1=a2=a j represents the split size in the sample;
[0030] S2: Set a suitable hyperparameter n state , that is, the number of sub-Gaussians is the number of nodes in the state diagram, for the newly divided Fit the Gaussian mixture model to obtain a trained Gaussian mixture model;
[0031] S3: In order to measure the change law within each heartbeat time series subsequence sample and calculate the transfer matrix, the heartbeat time series subsequence sample is divided into two sections, namely, the front section includes {a1, a2, …, a j-1}, the latter part includes {a2,a3,…,a j}, the posterior probability of each sample of the heartbeat time series is calculated by the trained Gaussian mixture model. The posterior probability is The probability distribution of each small block in ;
[0032] S4: According to the formula Calculate the transfer matrix The transfer matrix is the constructed state graph, where v represents a state of each node in the graph, t is a certain moment, and X t is the time series segment, θ v is the state mode, P(θ v |X t-1 ) is the heartbeat time series segment X t The posterior probability of which state mode it belongs to. Each edge represents the transition relationship of the heartbeat data from v to v'. This transition relationship is the state diagram of the heartbeat time series data. i} state evolution diagram, marked as {G i}, the state evolution diagram of the heartbeat time series with existing labels is denoted as {G L}, the unlabeled heartbeat time series state evolution diagram is denoted as {G U};
[0033] Step 2: Construct a balanced graph comparison learning sample
[0034] For any state graph mt i Flatten the matrix into a vector and calculate mt i With m ti+1 After multiplying the vectors and dividing by the modulus, we get Calculate similarity, where i=1,2,..., represents the number of state diagrams, which is also the number of heartbeat time series samples. Calculate the pairwise similarity between samples according to the time axis of the heartbeat time series and mark the similarity and dissimilarity. Here, if the cos similarity is greater than 0.5, it means that the paired graph samples are similar, that is, marked as 1; if the cos similarity is less than 0.5, it means that the paired graph samples are dissimilar, that is, marked as -1;
[0035] Step 3: Perform constrained graph representation comparative learning on paired graphs
[0036] After doing Fourier transform on the graph, we can get the approximate convolution formula of the graph Where D is the degree matrix, A is the adjacency matrix, H (l) is the node representation, W (l) is a learnable parameter, and according to this formula, the neural network can be directly trained through the following steps: S1: All constructed graphs G i All of them pass through the graph neural network. In the last layer of the graph neural network, a maximum pooling layer is used, that is, the node representation of the graph is converted into a vector representation of the graph by selecting the maximum value of each node representation. A linear layer is added to the graph representation to convert the output of the graph neural network output into Where C represents the number of categories;
[0037] S2: For each graph G i The vector representation of the empirical distribution f is obtained through the softmax function θ (G i ), where the empirical distribution is defined as: Where N is the number of subsequences divided in the heartbeat time series sample;
[0038] S3: Calculate the KL divergence for the average empirical distribution of the paired P = (G1, G2). The loss function used in the present invention is constructed by applying a hinge loss on the KL divergence, specifically: Where ρ is the marginal parameter of hinge loss, P S Represents similar graph pairs, P D Represents dissimilar pairs of images;
[0039] S4: The GCN network is trained according to this loss function: Where P L represents a labeled image pair, P U represents an unlabeled graph pair, λ R It is a fine-tunable parameter, usually ranging from 0 to 1, in order to constrain the balance between labeled samples and unlabeled samples in the entire batch;
[0040] Step 4: Train the classifier
[0041] For the input state diagram G i After the graph neural network f θ The obtained representation is then subjected to the maximum pooling to obtain the graph vector representation, which can be used as a classifier network f ψ The training classifier goes through the following steps:
[0042] S1: A 2-layer feedforward neural network followed by a softmax function is used to obtain the distribution of different categories. The labeled and unlabeled graphs (corresponding to the generated Gaussian state graph pairs) can be input into the classification network f ψ middle;
[0043] S2: Since the learned representation encourages unlabeled data points to gather around labeled data points, entropy regularization is used to utilize unlabeled data by encouraging the classifier boundary to pass through low-density areas. The current training data is composed of G L and G U Two sets, G L Each element in contains a pair (Z i ; Y i ), where Z i It represents the state diagram G i Vector representation obtained through graph neural network Y i For the heartbeat time series s i One-hot encoded labels ( C is the number of categories), G U Each element in is constructed through a Gaussian state diagram (i.e., the set P U (sample in );
[0044] S3: The loss function of the classifier network f is: where λ C is a fine-tunable parameter. represents the cross entropy loss, is the negative cross entropy loss, C is the number of categories, f θ represents the output of a feedforward classification network, which ends up with a softmax distribution, f ψ The input is through the network f θ The learned representation, for unlabeled data, the negative cross entropy loss function encourages the classification network f ψ Producing a lower entropy empirical class distribution, which encourages unlabeled data to be mapped to a single-class distribution, promoting f ψ The classification boundary is moved to a low-density area.
Claims
1. A heartbeat anomaly detection method based on semi-supervised graph contrast learning, which specifically includes the following steps: Step 1: Constructing a state diagram for heartbeat time series data The number of nodes in the state diagram is determined by the number of sub-Gaussians in the mixed Gaussian model, which is used as the hyperparameter n in the model. state , and the initialization attribute characteristics of the state diagram are obtained by concatenating the mean and variance of each Gaussian row by row, through the following steps: S1: For the heartbeat time series sample s i ∈R n×m , cut each heartbeat time series sample into s i ={s ia1 ,s ia2 ,…,s iaj }, where a=a1=a2=a j represents the split size in the sample; S2: Set a hyperparameter n state , that is, the number of sub-Gaussians is the number of nodes in the state diagram, for the newly divided Fit the Gaussian mixture model to obtain a trained Gaussian mixture model; S3: In order to measure the change law within each heartbeat time series subsequence sample and calculate the transfer matrix, the heartbeat time series subsequence sample is divided into two sections, namely, the front section includes {a1, a2, …, a j-1 }, the latter part includes {a2,a3,…,a j }, the posterior probability of each sample of the heartbeat time series is calculated by the trained Gaussian mixture model. The posterior probability is The probability distribution of each small block in ; S4: According to the formula Calculate the transfer matrix The transfer matrix is the constructed state graph, where v represents a state of each node in the graph, t is a certain moment, and X t is the time series segment, θ v is the state mode, P(θ v |X t-1 ) is the heartbeat time series segment X t The posterior probability of which state mode it belongs to. Each edge represents the transition relationship of the heartbeat data from v to v′. This transition relationship is the state diagram of the heartbeat time series data. i } state evolution diagram, marked as {G i }, the state evolution diagram of the heartbeat time series with existing labels is denoted as {G L }, the unlabeled heartbeat time series state evolution diagram is denoted as {G U }; Step 2: Construct a balanced graph comparison learning sample For any state graph mt i Flatten the matrix into a vector and calculate mt i With mt i+1 After multiplying the vectors and dividing by the modulus, we get Calculate similarity, where i = 1, 2, ..., represents the number of state diagrams, which is also the number of heartbeat time series samples. Calculate the pairwise similarity between samples according to the time axis of the heartbeat time series and mark the similarity and dissimilarity. Here, if the cos similarity is greater than 0.5, it means that the paired graph samples are similar, that is, marked as 1; if the cos similarity is less than 0.5, it means that the paired graph samples are dissimilar, that is, marked as -1; Step 3: Perform constrained graph representation comparative learning on paired graphs After doing Fourier transform on the graph, we can get the approximate convolution formula of the graph Where D is the degree matrix, A is the adjacency matrix, H (l) is the node representation, W (l) is a learnable parameter, and according to this formula, the neural network can be trained directly through the following steps: S1: All constructed graphs G i All of them pass through the graph neural network. In the last layer of the graph neural network, a maximum pooling layer is used, that is, the node representation of the graph is converted into a vector representation of the graph by selecting the maximum value of each node representation. A linear layer is added to the graph representation to convert the output of the graph neural network output into Where C represents the number of categories; S2: For each graph G i The graph shows the empirical distribution f obtained by the softmax function θ (G i ), where the empirical distribution is defined as: Where N is the number of subsequences divided in the heartbeat time series sample; S3: Calculate the KL divergence for the average empirical distribution of the paired P = (G1, G2). The loss function of this application is constructed by adding a hinge loss to the KL divergence, specifically: Where ρ is the marginal parameter of hinge loss, P S Represents similar graph pairs, P D Represents dissimilar pairs of images; S4: GCN network training according to this loss function: Where P L represents a labeled image pair, P U represents an unlabeled graph pair, λ R It is a fine-tunable parameter with an adjustment range of 0 to 1. U The balance between labeled samples and unlabeled samples in a batch; Step 4: Train the classifier For the input state diagram G i After the graph neural network f θ The obtained representation is then subjected to the maximum pooling to obtain the graph vector representation, which is used as a classifier network f ψ The training classifier goes through the following steps: S1: A 2-layer feedforward neural network followed by a softmax function is used to obtain the distribution of different categories, labeled and unlabeled graphs, which correspond to the generated Gaussian state graph pairs and are input to the classification network f ψ middle; S2: Since the learned representation encourages unlabeled data points to gather around labeled data points, entropy regularization is used to utilize unlabeled data by encouraging the classifier boundary to pass through low-density areas. The current training data is composed of G L and G U Two sets, G L Each element in contains a pair (Z i ; Y i ), where Z i It represents the state diagram G i Vector representation obtained through graph neural network Y i For the heartbeat time series s i One-hot encoded labels, C is the number of categories, G U Each element in is constructed through a Gaussian state diagram, that is, the set P U Samples in S3: The loss function of the classifier network f is: where λ C is a fine-tunable parameter. represents the cross entropy loss, is the negative cross entropy loss, C is the number of categories, f θ represents the output of the feedforward classification network, which ends with a softmax distribution, f ψ The input is through the network f θ The learned representation, for unlabeled data, the negative cross entropy loss function encourages the classification network f ψ Produces a lower entropy empirical class distribution, which encourages unlabeled data to be mapped to a single class distribution, promoting f ψ The classification boundary is moved to a low-density area.