**5.2. Recognization of ECG signals**

After ECG signals have been abstracted completely by the methods described in Section 5.1, they are used to train VAE model. To compare the effect of the complexity of ECG data on our model, all ECG data are divided into two groups. The first one contains only two classes of ECG records, normal or abnormal. (We call this group as BI dataset) The normal ECG records mean those ones that contain all normal features as shown in **Figures 4** and **5**. The abnormal ECG records in BI dataset contain at least one abnormal feature such as prolonged PR interval, enlarged P-wave, and absence of T-wave. The second group contains 8 classes of ECG records, each of them are produced by zeroing a small segment of ECG

**Figure 4.** An example of ECG signals that is composed by two parts of the adjacent semi-period. (a) Single period ECG signal between the adjacent R peaks derived by algorithm 1. (b)–(d) are different class ECG signals derived by making a small segment of the same ECG signal zero on different position. The difference is marked by red rectangle area.

**Figure 5.** Single periodic ECG signal polluted by different noises. (a) Original ECG signal without adding noise. (b) ECG signal of (a) with Gaussian noise. (c) Original ECG signal with a segment- flatness. (d) ECG signal of (c) contaminated by Gaussian and sine wave noise imitating basing line wander.

data as described in Section 5.1 (We call this group as MI dataset). In order to verify the performance of the VAE model on ECG signals, the parameters of the model are shown in the **Table 1**. **Table 2** shows the performance of the VAE model on recognizing these ECG signals from both BI and MI datasets. The results clearly show that the accuracies of recognition are higher than 95% for MI recorders and even more than 97% for BI recorders. In the view of the data complexity, the result is reasonable because the complexity of MI is much higher than that of BI.

Advantages of VAE model on recognization ECG signals can be further shown by comparasion with other autoecoders such as CAE,DAE, and SAE mentioned in Section 2. In order to make the comparison be fair and reasonable, all of the parameters of the model are the same exept for that of the sampler in VAE model (the values of the parameters can be seen in **Table 1**). Moreover, the ECG records of BI and MI from ahadb database are used to train and test all the models. **Figure 6** shows the accuracy of the models on recognizing the ECG records. Both **(a)** and **(b)** in **Figure 6** take the rate of the representation to the input on size as variable. **Figure 6(a)** takes the BI ECG records from the ahadb as the datasource for the models. Conversely, the MI


**Table 1.** Parameters of VAE model.

The AHA ECG database, the APNEA ECG database [24], and CHFDB ECG database [24]. Additionally, for ECG data augmentation [32], these ECG data are divided into three different groups according to their source databases and each group has 10,000 ECG signals. On this basis, we augment the ECG data by zeroing a small segment on ECG signals and different positions we selected to zero correspond to different class labels. **Figure 4(b)**–**(d)** are three examples of our augmentation. Concretely, the labels of **Figure 4(b)**–**(d)** are 3, 4, and 5, respectively. (We use numbers 1–8 as eight labels for different class of ECG signals in all of our experiments. We add labels for the different classes of ECG signals, not for training our models but for simplifying evaluating the accuracy of our models in testing

To evaluate the properties of our models on denoising for ECG signals, different type noise on different level are added into the original ECG records. These noise include Gaussian noise, salt and pepper noise, and Poisson noise. Moreover, to imitate baseline wandering noise, different amplitude sinusoidal signals are superimposed on the original ECG signals. The coefficients of the sinusoidal signal are 0.01, 0.05, and 0.1, respectively in all of our experiments. **Figure 5** shows the ECG signals polluted by different noises. **Figure 5(a)** and **(c)** show the augmented ECG signals without adding noise except for some one polluted during sampling. **Figure 5(b)** shows ECG signal polluted by the sinusoidal noise and the Gaussian noise. The coefficients for the sinusoidal and for the Gaussian are all 0.01. Nevertheless, the coefficients for the sinusoidal and for the Gaussian are 0.05 and 1 as shown in **Figure 5(d)**. The mean and

After ECG signals have been abstracted completely by the methods described in Section 5.1, they are used to train VAE model. To compare the effect of the complexity of ECG data on our model, all ECG data are divided into two groups. The first one contains only two classes of ECG records, normal or abnormal. (We call this group as BI dataset) The normal ECG records mean those ones that contain all normal features as shown in **Figures 4** and **5**. The abnormal ECG records in BI dataset contain at least one abnormal feature such as prolonged PR interval, enlarged P-wave, and absence of T-wave. The second group contains 8 classes of ECG records, each of them are produced by zeroing a small segment of ECG

**Figure 4.** An example of ECG signals that is composed by two parts of the adjacent semi-period. (a) Single period ECG signal between the adjacent R peaks derived by algorithm 1. (b)–(d) are different class ECG signals derived by making a small segment of the same ECG signal zero on different position. The difference is marked by red rectangle area.

variance of the Gaussian noise are 0 and 0.01, respectively.

**5.2. Recognization of ECG signals**

process.)

82 Machine Learning and Biometrics


**Table 2.** Performance evaluation of VAE model on three ECG databases.

records from the same dataset are selected in **Figure 6(b)**. It is clear that the accuracy of the VAE model is higher than that of the other models on both BI and MI ECG records, which is at leat 95% on BI records and no more than 90% on MI records. Meanwhile, both figures indicate a fact that the proper rate for the accuracy on the same condition is at 1. The accruy is near 80% when rate falls at 0.5. Simlarly, the accury drops sharply as the rate rise up. Therefore, there is no necessary for representation of ECG signals to compress (rate < 1) or stetch (rate > 1) themselves.

**Figure 7** demostrates the performance of the VAE model on denoising for ECG records. The method of adding noise into ECG records in our experiment can be seen in Section 5.1. The coefficient for sinusoidal is 0.05 and the mean and the variance of Gaussian noise are 0 and 0.05, respectively. For the goal of comparison, we take four groups of ECG records (BI, noisy BI, MI and noisy MI) as dataset for the VAE model.

The results show that the accuracy under noisy condition is similar to that of without noise on the same dataset. This means that performance of VAE model on ECG recognition is robust

**Figure 7.** The performance of the VAE model on denoising for ECG records.

**Figure 6.** Accuracy of different models on recognition ECG signals from aha database. (a) Accuracy of the models on recognizing ECG signals from BI dataset of ahadb ECG database. (b) Accuracy of the models on recognizing ECG signals

Electrocardiogram Recognization Based on Variational AutoEncoder

http://dx.doi.org/10.5772/intechopen.76434

85

to some kinds of noises.

from MI dataset of ahadb ECG database.

**Figure 6.** Accuracy of different models on recognition ECG signals from aha database. (a) Accuracy of the models on recognizing ECG signals from BI dataset of ahadb ECG database. (b) Accuracy of the models on recognizing ECG signals from MI dataset of ahadb ECG database.

**Figure 7.** The performance of the VAE model on denoising for ECG records.

records from the same dataset are selected in **Figure 6(b)**. It is clear that the accuracy of the VAE model is higher than that of the other models on both BI and MI ECG records, which is at leat 95% on BI records and no more than 90% on MI records. Meanwhile, both figures indicate a fact that the proper rate for the accuracy on the same condition is at 1. The accruy is near 80% when rate falls at 0.5. Simlarly, the accury drops sharply as the rate rise up. Therefore, there is no necessary for representation of ECG signals to compress (rate < 1) or stetch (rate > 1)

**) Class no. Precision (%) Error (%)**

**Figure 7** demostrates the performance of the VAE model on denoising for ECG records. The method of adding noise into ECG records in our experiment can be seen in Section 5.1. The coefficient for sinusoidal is 0.05 and the mean and the variance of Gaussian noise are 0 and 0.05, respectively. For the goal of comparison, we take four groups of ECG records (BI, noisy

themselves.

BI, MI and noisy MI) as dataset for the VAE model.

**Table 2.** Performance evaluation of VAE model on three ECG databases.

**DB Record ECG no. Sample no. (103**

84 Machine Learning and Biometrics

ahadb 0001 0 10 2 97.70 2.30 ahadb 0001 0 10 8 96.31 3.69 ahadb 0001 1 10 2 96.63 3.37 ahadb 0001 1 10 8 93.91 6.09 ahadb 0201 0 10 2 99.87 0.13 ahadb 0201 0 10 8 96.58 3.42 ahadb 0201 1 10 2 98.10 1.90 ahadb 0201 1 10 8 98.25 1.75 APNEA a01 0 0.7 2 98.02 1.98 APNEA a01 0 0.7 8 97.56 2.44 APNEA a02 0 0.8 2 99.87 0.13 APNEA a02 0 0.8 8 95.74 4.26 CHFDB Chf01 0 10 2 99.99 0.01 CHFDB Chf01 0 10 8 97.65 2.35 CHFDB Chf01 1 10 2 98.89 1.11 CHFDB Chf01 1 10 8 96.45 3.55 CHFDB Chf01 0 10 2 99.75 0.25 CHFDB Chf01 0 10 8 96.78 3.22 CHFDB Chf01 1 10 2 99.26 0.74 CHFDB Chf01 1 10 8 97.92 2.08

> The results show that the accuracy under noisy condition is similar to that of without noise on the same dataset. This means that performance of VAE model on ECG recognition is robust to some kinds of noises.
