Twelve-lead heart beat classification method based on ensemble learning and two-level hierarchical network
The twelve-lead heartbeat classification method through integrated learning and two-level hierarchical network, combined with wavelet transform and CNN/LSTM network, solves the problems of low interpretation efficiency and poor classification effect of traditional electrocardiogram multi-lead data, and achieves arrhythmia detection Intelligent identification and efficient classification have improved the intelligent level of ECG monitoring.
Patent Information
- Application Number
- CN202211256703.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-14
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2042-10-14
AI Technical Summary
Traditional multi-lead data interpretation of electrocardiograms relies on manual analysis, which cannot meet the rapidly growing demand for cardiovascular disease diagnosis, and suffers from poor classification results.
A twelve-lead heart beat classification method based on integrated learning and a two-level hierarchical network is used to extract and classify features through discrete wavelet transform, Mallat algorithm denoising, adaptive sliding window algorithm to intercept heart beats, and 1-D CNN and LSTM network structures. , combined with the weighted voting method to fuse the output results of different lead channels to achieve intelligent identification of arrhythmia.
It improves the overall performance index of arrhythmia classification, relieves the interpretation work pressure of medical staff, and provides new ideas for intelligent interpretation for ECG monitoring in the smart medical field.
Smart Images

Figure CN115429288B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of machine learning and deep learning, and specifically relates to a twelve-lead heartbeat classification method based on ensemble learning and a two-level hierarchical network. Background Art
[0002] Cardiovascular diseases (CVD) have long been one of the factors causing major disease burdens worldwide. The number of people suffering from cardiovascular diseases in China has increased year by year, and the prevalence rate has continued to rise, causing a heavy medical burden on the people. Electrocardiogram is a non-invasive tool for detecting heart health. The electrocardiogram signals contained in it record the electrophysiological activity of the heart and important pathological information in the human heart, which is of great significance for the classification and research of cardiovascular diseases. Traditional electrocardiograms contain 12-lead data, including 6 limb leads (I, II, III, aVR, aVL, aVF) and 6 chest leads (V1-V6). Different lead data show different waveform characteristics. Especially for some difficult-to-distinguish categories, it is necessary to observe the electrocardiogram performance of different leads for comprehensive judgment. Therefore, in the interpretation of clinical electrocardiograms, multi-lead data is often used to cooperate with electrocardiogram interpretation. However, with the increasing number of patients with cardiovascular diseases, the electrocardiogram screening work faced by doctors has become more and more arduous. Only relying on doctors to analyze electrocardiograms by manual screening cannot meet the current medical needs. Therefore, it is necessary to accelerate the research and application of intelligent ECG monitoring. Summary of the invention
[0003] The purpose of the present invention is to provide a twelve-lead heart beat classification method based on ensemble learning and a two-level hierarchical network, to achieve intelligent classification and identification of five major types of arrhythmias, to help assist doctors in ECG interpretation, to establish a more complete ECG monitoring system, and to accelerate the intelligent research and application of ECG monitoring.
[0004] To achieve the above object, the technical solution of the present invention is: a twelve-lead heartbeat classification method based on ensemble learning and a two-level hierarchical network, comprising the following steps:
[0005] Step S1, preprocessing the twelve-lead ECG data;
[0006] Step S2, performing heart beat interception and classification on the ECG data obtained by preprocessing in step S1;
[0007] Step S3, a two-level hierarchical network is proposed, the first level network outputs normal heartbeats and abnormal heartbeats, and the second level network outputs specific corresponding abnormal heartbeat classifications;
[0008] Step S4, repeat the operation of step S3 to complete the twelve-lead data training;
[0009] Step S5: Based on the idea of ensemble learning, the network output results of different lead channels in step S4 are integrated;
[0010] Step S6: Integrate the output results of the first-level network and the second-level network to finally obtain the five-category heartbeat classification result.
[0011] In one embodiment of the present invention, step S1 specifically includes the following steps:
[0012] Step S11: for the input 12-lead ECG data, use discrete wavelet transform and Mallat algorithm to perform multi-level decomposition on the ECG noisy signal to obtain multi-layer ECG decomposition signals of different frequency bands;
[0013] Step S12, filtering out the frequency band corresponding to the high-frequency noise signal and the baseline drift signal generated during the ECG acquisition process;
[0014] Step S13: reconstruct the multi-layer decomposition signal after the noise is filtered out to obtain the filtered ECG data.
[0015] In one embodiment of the present invention, step S2 specifically includes the following steps:
[0016] Step S21, using an adaptive sliding window algorithm to locate the position of the R wave;
[0017] Step S22, taking the sampling point at the R wave as the origin, intercepting 100 and 150 sampling points to the left and right respectively, to obtain a complete heart beat with 250 sampling points, i.e., about 0.7s;
[0018] Step S23, according to the AAMI standard, the arrhythmia beats are divided into five categories, namely, category N, i.e., normal or bundle branch block beats, category S, i.e., supraventricular abnormal beats, category V, i.e., ventricular abnormal beats, category F, i.e., fusion beats, and category Q, i.e., beats that cannot be classified;
[0019] Step S24: Divide all ECG data into two data sets evenly, one set as a training set and the other set as a test set, and the two data sets are strictly independent.
[0020] In one embodiment of the present invention, step S3 specifically includes the following steps:
[0021] Step S31, the first level network is designed for positive and abnormal classification of heart beats, so 1-D CNN is selected to implement preliminary binary classification work;
[0022] Step S32: For the first-level network, the cut heartbeat data is input into the convolution layer, which is responsible for extracting the features of the input vector. The activation layer is responsible for performing nonlinear changes on the network. The ReLU activation function is used. After two convolution and activation operations, the output feature vector is first input into the maximum pooling layer for downsampling, and then input into the Dropout layer for random network node inactivation. After five times of the above operation, the feature vector is input into the fully connected layer, and finally the result is output to obtain the label output of N categories and other categories.
[0023] Step S33, the second-level network is designed to perform classification output of four heartbeat categories other than category N, so it is necessary to improve the basic 1-D CNN for multi-classification work, that is, adopt a network structure of 1-D CNN and LSTM serial, 1-D CNN is used to extract waveform features of input data, and LSTM is used to extract time series features of input data;
[0024] Step S34, for the second-level network, the cut heartbeat data is input into the convolution layer, and adjusted in the convolution layer. One convolution layer, one activation layer, one maximum pooling layer and one Dropout layer are used; after repeating the 1-D CNN structure 4 times, the output feature vector is input into the LSTM, and the activation function used in the LSTM is the Sigmoid function. After the LSTM, a Flatten layer is added to convert the multi-dimensional input into one dimension, so that the input finally connected to the fully connected layer and the Dropout layer is a one-dimensional vector, and the final network outputs four categories of S, V, F, and Q.
[0025] In one embodiment of the present invention, step S4 specifically includes the following steps:
[0026] Step S41, in the first level network, the twelve-lead data are used as twelve channels and are respectively input into the 1-D CNN. After passing through several convolutional layers and Dropout layers, the output feature vector is output as a one-dimensional vector through the fully connected layer. Finally, the network of the twelve channels obtains twelve outputs respectively.
[0027] Step S42: In the second-level network, the twelve-lead data are taken as twelve channels and respectively input into the integrated model of 1-D CNN and LSTM. After several convolution operations, they are input into LSTM for time series feature extraction, and then output as a one-dimensional vector through the fully connected layer. Finally, the network of the twelve channels obtains twelve outputs respectively.
[0028] In one embodiment of the present invention, step S5 specifically includes the following steps:
[0029] Step S51: Based on the idea of ensemble learning, the weighted voting method is used to fuse the twelve output results of the first-level network, and the one-dimensional vectors of the twelve outputs are weighted to finally obtain a weighted one-dimensional vector. The vector records the probability that the input sample belongs to class N or other classes, and the label corresponding to the maximum probability value is the final category label of the output, thereby obtaining the binary classification results of class N and other classes;
[0030] Step S52: The twelve output results of the second-level network are also fused by the weighted voting method, and the one-dimensional vectors of the twelve outputs are weighted to finally obtain a weighted one-dimensional vector. The vector records the probability value of the input sample belonging to the S, V, F or Q class, where the label corresponding to the maximum probability value is the final category label of the output, thereby obtaining the four-category classification result of the S, V, F or Q class.
[0031] In one embodiment of the present invention, step S6 specifically includes the following steps:
[0032] Step S61, integrating the N-category labels outputted from the first-level network and the four-category labels outputted from the second-level network, and finally obtaining heartbeat classification results of five categories, namely, category N, category S, category V, category F, and category Q;
[0033] Step S62: The final integrated model is predicted on the test set, and according to the AAMI standard, three indicators are specified for evaluating the performance of the arrhythmia classification algorithm, namely, accuracy Acc, sensitivity Sen, and positive predictive value Ppv.
[0034] Compared with the prior art, the present invention has the following beneficial effects: the method of the present invention adopts twelve-lead ECG data as input, establishes a multi-input heart beat classification integrated model based on convolutional neural network and long short-term memory network, adopts integrated learning method and two-level hierarchical network in the model, combines different individual classifiers to build an integrated learning model framework, solves the problem of poor classification effect of unbalanced data sets, thereby effectively improving the overall performance index of arrhythmia classification, and is expected to alleviate the heavy interpretation work pressure of medical staff, and provide new ideas for the intelligent interpretation research of ECG in the field of smart medical care. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 It is a schematic flow chart of the method of the present invention;
[0036] Figure 2 It is a schematic diagram of the overall framework flow of the two-level hierarchical network model in the present invention. DETAILED DESCRIPTION
[0037] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings.
[0038] Please refer to Figure 1 The present invention provides a twelve-lead heartbeat classification method based on ensemble learning and a two-level hierarchical network, comprising the following steps:
[0039] Step S1, performing preprocessing operations such as wavelet transform denoising and baseline drift removal on the 12-lead ECG data to obtain a denoised and reconstructed ECG signal;
[0040] Step S2, performing complete heart beat interception and classification on the ECG data set processed in step S1, and dividing it into a training set and a test set;
[0041] Step S3: Due to the uneven distribution of the data set, normal heartbeats generally account for three quarters of the total number of heartbeats. Therefore, a two-level hierarchical network is proposed. The first-level network outputs normal heartbeats and abnormal heartbeats, and the second-level network outputs specific corresponding abnormal heartbeats.
[0042] Step S4 and step S3 are only for single-lead data training, so the twelve-lead data training needs to repeat the operation of step S3;
[0043] Step S5: Based on the idea of ensemble learning, a weighted voting method is used to fuse the network output results of different lead channels in step S4;
[0044] Step S6, integrate the output results of the first-level and second-level networks in step S5, and finally obtain the five-category heartbeat classification results; after the model is built, use the integrated model to test the test set to obtain the final prediction result.
[0045] In this embodiment, step S1 is specifically as follows:
[0046] The wavelet transform algorithm is used to perform multi-level decomposition of ECG noisy signals, and the noise is filtered out through analysis. According to the spectrum analysis, it can be known that the energy of ECG signals is mainly concentrated in the range of 0.5Hz-45Hz. Since the database sampling rate is 360Hz, discrete wavelet transform is used for wavelet decomposition, and the decomposition is at least 8 layers. After the original signal passes through the low-pass filter and the high-pass filter, the two signals are double-sampled and finally the approximation and detail coefficients of each level are obtained.
[0047] The detail coefficients of the first and second layers mainly contain high-frequency noise signals generated during ECG acquisition, with a frequency range of 45Hz-180Hz, so they cannot be used when reconstructing ECG data. The baseline drift signal of the ECG is mainly concentrated in the approximate coefficients of the eighth layer, which are also set to zero during reconstruction to remove the baseline drift. In summary, after reconstruction, both baseline drift and noise are effectively suppressed.
[0048] In this embodiment, step S2 is specifically as follows:
[0049] 1. A standard complete heartbeat should include P wave, Q wave, R wave, S wave and T wave, so when intercepting the heartbeat, it is important to keep the integrity of the heartbeat. The method used in this embodiment is based on the position of the R wave, and several points are taken forward and backward respectively, so as to intercept a complete heartbeat. The position of the R wave is located by an adaptive sliding window algorithm. When the position of the R wave is confirmed, 100 and 150 sampling points can be intercepted to the left and right respectively by taking the sampling point at the R wave as the origin, and finally a complete heartbeat with 250 sampling points (about 0.7s) is obtained. The point selection standard is based on the basic heart rate of a person of about 60-100 beats / min, that is, the heart beats once in about 0.6-1s, so 0.7s, that is, 250 points, are taken as a complete heartbeat.
[0050] 2. The AAMI standard describes heartbeat categories as five major arrhythmia categories, namely, Category N (normal or bundle branch block heartbeat), Category S (supraventricular abnormal heartbeat), Category V (ventricular abnormal heartbeat), Category F (fusion heartbeat), and Category Q (unclassified heartbeat); therefore, this embodiment uses these five major arrhythmia categories as data categories for subsequent research.
[0051] 3. Divide all ECG data into two sets of data evenly, one set as the training set and the other set as the test set. The two sets of data are strictly independent.
[0052] In this embodiment, step S3 is specifically as follows:
[0053] Since the imbalance of central electrostatic data in the dataset is serious, a two-level hierarchical network structure is adopted when designing the model. The overall framework process of the model is as follows: Figure 2 shown.
[0054] Since the first-level network is designed for the classification of positive and abnormal heartbeats, a 1-D CNN model with a relatively simple network structure is considered to be selected for the initial two-classification work. The second-level CNN network is mainly used for the classification output of four heartbeat categories other than N categories, so it is necessary to improve the basic 1-D CNN network for multi-classification work; in this embodiment, a 1-D CNN and LSTM serial network structure is used, and the 1-D CNN is mainly used to extract the waveform features of the input data, and the LSTM is mainly used to extract the time series features of the input data.
[0055] For the first level network, the specifics are:
[0056] 1. First, the input layer will standardize the input one-dimensional time series into a 187*1 vector.
[0057] 2. The vector output by the input layer is input into the convolution layer and the activation layer. The convolution layer is mainly responsible for extracting the features of the input vector, and the activation layer is responsible for making nonlinear changes to the network. The ReLU activation function is used. The gradient of the ReLU function is stable. Even if the input value is very small, the gradient will not disappear. In addition, the overall calculation of the function is simple, which can improve the overall convergence speed of the network. The calculation formula is as follows:
[0058] f(x) = max(0, x)
[0059] 3. After two convolution and activation operations, the output feature vector is input into the maximum pooling layer for downsampling, and then input into the Dropout layer for random network node inactivation to avoid overfitting of the network.
[0060] 4. After the above operation is performed 5 times, the feature vector is input into the fully connected layer, and the result is finally output to obtain the label output of N categories and other categories. Since the first-level network is a binary classification output, the last fully connected layer responsible for the output uses the Sigmoid activation function, and the loss function used in the training process is the binary cross entropy function (BinaryCrossentropy), and the calculation formula is as follows:
[0061]
[0062] Among them, y represents the true label, Represents the predicted label.
[0063] For the second-level network, the details are:
[0064] 1. First, the input layer will standardize the input one-dimensional time series into a 187*1 vector.
[0065] 2. The vector output by the input layer is input into the convolution layer, where it is adjusted to make the overall network structure lighter. Considering that the overall convergence speed of the LSTM network is relatively slow, in order to ensure that the overall network operation rate is not too low, a convolution layer, an activation layer, a maximum pooling layer, and a Dropout layer are finally used.
[0066] 3. After repeating the above 1-D CNN structure 4 times, the output feature vector is input into the LSTM network. The activation function used in LSTM is different. The Sigmoid function is used. This is because the activation function appears in the form of a gate function in the network for the construction of the LSTM network. Therefore, the output value of the activation function is required to be between 0 and 1. The calculation formula of the Sigmoid function is as follows:
[0067]
[0068] 4. After the LSTM network, a Flatten layer is added, which is mainly used to convert the multi-dimensional input into one dimension, so that the input finally connected to the fully connected layer is a one-dimensional vector, and the network finally outputs four categories: S, V, F, and Q. Since the second-level network needs to output four categories, it is a multi-classification problem. Therefore, the last fully connected layer responsible for the output uses the Softmax activation function, and the loss function used in the training process is the cross entropy loss function (Categorical Crossentropy Loss), and the calculation formula is as follows:
[0069]
[0070] Where N represents the total number of samples, K represents the number of label values, i.e. the number of categories, y represents the actual data label, and p represents the probability that a sample is predicted to be a certain category.
[0071] In this embodiment, step S4 is specifically as follows:
[0072] In the first-level network, the twelve-lead data are used as twelve channels and input into the 1-D CNN model respectively. After passing through several convolutional layers and Dropout layers, the output feature vector is output as a one-dimensional vector through the fully connected layer. Finally, the network of the twelve channels obtains twelve outputs respectively.
[0073] In the secondary network, the twelve-lead data are also taken as twelve channels and input into the integrated model of 1-D CNN and LSTM network respectively. After several convolution operations, they are input into the LSTM network for time series feature extraction, and then output as a one-dimensional vector through the fully connected layer. Finally, the network of the twelve channels obtains twelve outputs respectively.
[0074] Since the model proposed in this embodiment is a two-level hierarchical network model, it is necessary to train the two networks separately during the training process, and use the trained model as the basic model to output the final result. In the process of training the two networks separately, a relatively consistent training strategy is adopted. Both networks use the Adam optimization algorithm, which can adaptively design a learning rate suitable for the current network convergence and realize adaptive adjustment of different parameters. The initial learning rate is set to 0.001.
[0075] At the same time, this embodiment uses the Early Stopping method to prevent the occurrence of overfitting during the model training process. This method aims to solve the problem that the number of iterations needs to be set manually. When the number of iterations set manually is too many, the model will be overfitted. However, if the number of iterations is insufficient, the model cannot fit the distribution of the data. Therefore, the Early Stopping method can be used to control the number of network iterations. The specific control method is as follows: during the model training process, a part of the test set data will be set as the verification set. Whenever the model performs a certain number of complete iterations based on the training set data, the verification set will be verified on the model parameters at this time, and the verification results will be output. If the output error does not continue to converge within a certain allowed number of iterations, the training process is stopped and the current weight is saved as the weight parameter of the network.
[0076] In this embodiment, step S5 is specifically as follows:
[0077] Under the integrated learning method, it is necessary to build individual classifiers first and then use a strategy to fuse and output the final results. That is, the primary network and the secondary network corresponding to the twelve leads need to be trained separately, and then the output results are fused using the weighted voting method to obtain the final training results.
[0078] During the training process, the heartbeat labels are first divided into two categories, one corresponding to N types of heartbeats and the other corresponding to other types of heartbeats. The data set is input into the model for binary classification training. The twelve training sets corresponding to the classified twelve-lead ECG data will each get an output after training in the first-level network. The twelve outputs are fused using the weighted voting method, and the output results of N or other categories are finally obtained. After that, the heartbeat data of four categories other than N are output. At this time, the number of heartbeat labels is 4, that is, the heartbeat data of four categories and the corresponding labels are trained for the second-level network, and twelve one-dimensional vector outputs are finally obtained. After these twelve outputs are fused, the output results of four categories of S, V, F, and Q are finally obtained.
[0079] In this embodiment, step S6 is specifically as follows:
[0080] The N-category labels output from the first-level network and the four-category labels output from the second-level network are integrated, and finally, five categories of heartbeat classification results, namely, category N, category S, category V, category F, and category Q, can be obtained;
[0081] The final integrated model is predicted on the test set. During the test, the test set data of the twelve leads are first sent to the first-level network for binary classification, and the results of the twelve channels are weighted and fused to output. Finally, the classification results of N and other four categories of heartbeats are output. The data labels classified as N in the output results of the first-level network are retained, and the twelve-lead heartbeat data corresponding to the remaining four categories are sent to the second-level network for four-classification testing. After passing the second-level network model, the twelve-channel output results also need to be weighted and fused to output, and finally the output results of four categories of S, V, F, and Q are obtained. Integrating the N-category data labels in the first-level network and the four category labels of the test output in the second-level network, the final recognition results of five categories of N, S, V, F, and Q can be obtained.
[0082] According to the AAMI standard, three indicators are specified for evaluating the performance of the arrhythmia classification algorithm of this embodiment, namely, accuracy (Accuracy, Acc), sensitivity (Sensitive, Sen) and positive predictive value (Positive Predictive Value, Ppv).
[0083] The accuracy rate represents the ability of the classification model to judge the overall samples, that is, the ability to judge each type of sample as that sample. The calculation formula is as follows:
[0084]
[0085] Sensitivity measures the ability of the classification model to judge positive samples, indicating the ratio of the number of correctly predicted positive samples to the number of true positive samples among all positive samples. The calculation formula is as follows:
[0086]
[0087] The positive prediction rate is a common prediction indicator in medicine, which measures the proportion of correctly predicted positive samples among all predicted positive samples. Its calculation formula is as follows:
[0088]
[0089] Among them, TP is True Positive, which means that the heartbeat samples of the normal category are correctly predicted; FN is False Negative, which means that the heartbeat samples of the normal category are predicted as abnormal; FP is False Positive, which means that the abnormal heartbeat is predicted as a heartbeat sample with a normal label; TN is True Negative, which means the samples of the abnormal category heartbeat are correctly predicted.
[0090] The above are preferred embodiments of the present invention. Any changes made according to the technical solution of the present invention, as long as the resulting functions do not exceed the scope of the technical solution of the present invention, belong to the protection scope of the present invention.
Claims
1. A twelve-lead heartbeat classification method based on ensemble learning and two-level hierarchical network, characterized in that: The following steps are involved: Step S1, preprocessing the twelve-lead ECG data; Step S2, performing heart beat interception and classification on the ECG data obtained by preprocessing in step S1; Step S3, a two-level hierarchical network is proposed, the first level network outputs normal heartbeats and abnormal heartbeats, and the second level network outputs specific corresponding abnormal heartbeat classifications; Step S4, repeat the operation of step S3 to complete the twelve-lead data training; Step S5: Based on the idea of ensemble learning, the network output results of different lead channels in step S4 are integrated; Step S6, integrating the output results of the first-level network and the second-level network to finally obtain the five-category heartbeat classification result; Step S1 specifically includes the following steps: Step S11: for the input 12-lead ECG data, use discrete wavelet transform and Mallat algorithm to perform multi-level decomposition on the ECG noisy signal to obtain multi-layer ECG decomposition signals of different frequency bands; Step S12, filtering out the frequency band corresponding to the high-frequency noise signal and the baseline drift signal generated during the ECG acquisition process; Step S13, reconstructing the multi-layer decomposition signal after filtering out noise to obtain filtered ECG data; Step S2 specifically includes the following steps: Step S21, using an adaptive sliding window algorithm to locate the position of the R wave; Step S22, taking the sampling point at the R wave as the origin, intercepting 100 and 150 sampling points to the left and right respectively, to obtain a complete heart beat of 250 sampling points, i.e. 0.7s; Step S23, according to the AAMI standard, the arrhythmia beats are divided into five categories, namely, category N, i.e., normal or bundle branch block beats, category S, i.e., supraventricular abnormal beats, category V, i.e., ventricular abnormal beats, category F, i.e., fusion beats, and category Q, i.e., beats that cannot be classified; Step S24, all ECG data are evenly divided into two sets of data sets, one set is used as a training set, and the other set is used as a test set, and the two sets of data sets are strictly independent; Step S3 specifically includes the following steps: Step S31, the first level network is designed for positive and abnormal classification of heart beats, so 1-D CNN is selected to implement preliminary binary classification work; Step S32: For the first-level network, the cut heartbeat data is input into the convolution layer, which is responsible for extracting the features of the input vector. The activation layer is responsible for performing nonlinear changes on the network. The ReLU activation function is used. After two convolution and activation operations, the output feature vector is first input into the maximum pooling layer for downsampling, and then input into the Dropout layer for random network node inactivation. After 5 times of the above operations, the feature vector is input into the fully connected layer, and finally the result is output to obtain the label output of N categories and other categories. Step S33, the second-level network is designed to perform classification output of four heartbeat categories other than category N, so it is necessary to improve the basic 1-D CNN for multi-classification work, that is, adopt a network structure of 1-D CNN and LSTM serial, 1-D CNN is used to extract waveform features of input data, and LSTM is used to extract time series features of input data; Step S34, for the second-level network, the cut heartbeat data is input into the convolution layer, and the convolution layer is adjusted. A convolution layer, an activation layer, a maximum pooling layer and a Dropout layer are used. After repeating the 1-D CNN structure 4 times, the output feature vector is input into the LSTM. The activation function used in the LSTM is the Sigmoid function. After the LSTM, a Flatten layer is added to convert the multi-dimensional input into one dimension, so that the input finally connected to the fully connected layer and the Dropout layer is a one-dimensional vector. Finally, the network outputs four categories of S, V, F, and Q. Step S4 specifically includes the following steps: Step S41, in the first level network, the twelve-lead data are taken as twelve channels and respectively input into the 1-D CNN. After passing through several convolutional layers and Dropout layers, the output feature vector is output as a one-dimensional vector through the fully connected layer. Finally, the network of the twelve channels obtains twelve outputs respectively. Step S42: In the second-level network, the twelve-lead data are used as twelve channels and are respectively input into the integrated model of 1-D CNN and LSTM. After several convolution operations, they are input into LSTM for time series feature extraction, and then output as a one-dimensional vector through a fully connected layer. Finally, the network of the twelve channels obtains twelve outputs respectively. Step S5 specifically includes the following steps: Step S51: Based on the idea of ensemble learning, the weighted voting method is used to fuse the twelve output results of the first-level network, and the one-dimensional vectors of the twelve outputs are weighted to finally obtain a weighted one-dimensional vector. The vector records the probability that the input sample belongs to class N or other classes, and the label corresponding to the maximum probability value is the final category label of the output, thereby obtaining the binary classification results of class N and other classes; Step S52: The twelve output results of the second-level network are also fused by weighted voting, and the twelve output one-dimensional vectors are weighted to finally obtain a weighted one-dimensional vector, in which the probability value of the input sample belonging to the S, V, F or Q class is recorded, and the label corresponding to the maximum probability value is the final category label of the output, thereby obtaining the four-category result of the S, V, F or Q class; Step S6 specifically includes the following steps: Step S61, integrating the N-category labels outputted from the first-level network and the four-category labels outputted from the second-level network, and finally obtaining heartbeat classification results of five categories, namely, category N, category S, category V, category F, and category Q; Step S62: The final integrated model is predicted on the test set, and according to the AAMI standard, three indicators are specified for evaluating the performance of the arrhythmia classification algorithm, namely, accuracy Acc, sensitivity Sen, and positive predictive value Ppv.
