search for


Optimal Classifier for Detection of Obstructive Sleep Apnea Using a Heartbeat Signal
Int. J. Fuzzy Log. Intell. Syst. 2017;17(2):76-81
Published online July 1, 2017
© 2017 Korean Institute of Intelligent Systems.

Erdenebayar Urtnasan1,2, Jong-Uk Park2, SooYong Lee3, and Kyoung-Joung Lee2

1Department of Medical Engineering, Huree University, Ulaanbaatar, Mongolia, 2Department of Biomedical Engineering, Yonsei University, Wonju, Korea, 3Liberal Education, Yonsei University, Wonju, Korea
Correspondence to: Kyoung-Joung Lee (
Received May 15, 2017; Revised June 24, 2017; Accepted June 24, 2017.
This is an Open Access article distributed under the terms of the Creative Commons Attribution Non-Commercial License ( which permits unrestricted non-commercial use, distribution, and reproduction in any medium, provided the original work is properly cited.

This study is to find the optimum classifier that can be easy and robust diagnostic method of the obstructive sleep apnea (OSA) using a heartbeat signal. The heartbeat signal was acquired from the 92 patients with OSA. The dataset consists 98,060 epochs, from them the training sets contained 68,642 epochs from the 63 OSA patients and test sets contained 29,418 epochs from the 29 OSA patients, respectively. The heartbeat signal was analyzed in the time and frequency domain and six features were extracted (normal-to-normal [NN], standard deviation of mean NN [SDNN], root mean square of successive differences [rMSSD], low-frequency [LF], high-frequency [HF], and LF/HF ratio). All extracted features were used to train the following classifiers: linear discriminant analysis (LDA), decision tree (DT), logistic regression (LR), k-nearest neighbor (KNN) and support vector machine (SVM). The top three classifiers (SVM, DT, and LDA) showed the accuracy of 93.2%, 93.2%, and 93.2% for test sets, respectively. Then, the top three classifiers could be effective on sleep studies and OSA detections.

Keywords : Obstructive sleep apnea, Machine learning, SVM, LR, DT, LDA, KNN
1. Introduction

Quality of sleep is affected by the quality of life. Obstructive sleep apnea (OSA) is a most common sleep-disordered breathing (SDB) which decrease the quality of sleep. OSA is defined as upper airway collapse at least 10 seconds during sleep. It can cause repetitive shortness of breath and sleep fragmentation, which degrade the quality of sleep and life [1]. In addition, OSA can lead to excessive fatigue, sleepiness, and even drowsy driving, which can result in traffic accidents and other more serious tragic consequences such as heart attacks and sudden death [25].

Polysomnography (PSG) is a standard method for objectively evaluating the SDB. An objective diagnosis of the SDB can be provided based on bio-signals given by polysomnography. However, polysomnography also has several drawbacks, such as the need for expensive diagnostic equipment, attachment of multiple sensors, and manual reading by experts [6]. Manual reading by sleep specialists, in particular, is time-consuming and labor-intensive. In addition, different results can be produced or errors can occur depending on the experience and subjective judgment of the specialist. A computerized SDB detection scheme can solve these problems. ECG signals are widely used for computerized OSA detection. Last decades, there were several algorithms proposed in the literature for automatic detection of OSA using a not only ECG signal but also oxygen saturation and respiratory effort signals. In those studies, various machine learning methods such as k-nearest neighbor (KNN) [7, 8], support vector machine (SVM) [9], AdaBoost [10], and neural network [11] were used for OSA detection. For instance, Xie and Minn [10] used classifier that combine AdaBoost with Decision Stump and Bagging with REPTree, and employed features extracted from ECG and saturation of peripheral oxygen (SpO2) signals. Khandoker et al. [9] used SVM with 28 features extracted from heart rate variability signal and ECG-derived respiration data to detect OSA. Varon et al. [11] also used principal components of the QRS complexes as features and classified using least-squares support vector machine. Nguyen et al. [12] performed heart rate complexity based on recurrence quantification analysis of heart rate variability to classify OSA episodes. However, since above methods used a number of features obtained from the various bio-signals, they were very complex and time consumed.

In this study, we used only few features from the one channel heartbeat signal for easy implementation. In addition, we found a optimal classifier using the feature set that we extracted for accurate classification of OSA. Only six features were extracted from the heartbeat signal and the following five methods were used as classifier to evaluate the performance: linear discriminant analysis (LDA), decision tree (DT), logistic regression (LR), KNN, and SVM.

2. Method

2.1 Study population

Ninety-two subjects (male: 73, female: 19) with OSA participated in this study. The data set was split into training and test sets for the machine learning algorithms. The training sets contained 68,642 epochs from the 63 OSA patients and test sets contained 29,418 epochs from the 29 OSA patients, respectively. The data set splits were the same for each of the methods used.

The apnea hypopnea index (AHI) was calculated by the number of occurrences of the apnea and hypopnea during total hours of sleep [13]. A subjects demographics and sleep-related variables were not significantly different between the training set and validation sets, as shown in Table 1. This study was authorized by the Institutional Review Board (No. IRB-2012-01-063) of Samsung Medical Center (SMC). All subjects provided written informed consent for participating.

2.2 Data recording

The standard full-night PSG data were analyzed and conducted using N7000 (Embla System Inc., Denver, Co, USA) in the Sleep Center of SMC. The average recording time was 7.37 hours and recorded channels are as following: EEG, EMG, EOG, ECG, chest and abdominal volume changes, nasal-oral airflow, body position, snoring, and blood oxygen saturation. The ECG were recorded at 200 samples/sec and stored with 16-bit resolution. According to an American Acamedy of Sleep Medicine (AASM) guideline [13], a trained sleep specialist scored PSG data from each subject every 30 seconds (1 epoch) using RemLogic 2.0 software.

2.3 Feature extraction

All six features were extracted from a heartbeat signal for OSA diagnosis. An ECG signal was processed with a bandpass filter (0.5–32Hz) to remove the noises. The heartbeat signals were found from filtered ECG using a Pan and Tompkins algorithm [14] and manually corrected.

The heartbeat signal was analyzed in the time and frequency domain to extract features. In the time domain, the features were calculated as the mean of normal-to-normal (NN) intervals, standard deviation of mean NN (SDNN), and root mean square of successive differences of last NN (rMSSD). The welch method was applied for the frequency domain analysis in every 30 seconds and extracted features were low-frequency (LF) power range (0.04–0.15 Hz), high-frequency (HF) power range (0.15–0.40 Hz), and LF/HF ratio.

All selected features are well known in sleep studies, also been used in the various studies which detects or classifies the OSA [811, 15, 16]. So that, they were selected and applied to five different methods of the machine learning to find the optimal one. The real value of the extracted features from a heartbeat signal are represented in Table 2.

2.4 Linear discriminant analysis

The LDA is the representative of the dimensionality reduction models that aims to summarize or describe data using less information. The LDA finds the direction vector such that projected data have the largest possible between-class separation while the within-class is kept as small as possible [15].

2.5 Logistic regression

The LR is an algorithm that constructs a separating hyperplane between two data sets, using the logistic function to express distance from the hyperplane as a probability of class membership. LR is widely used in medical applications for the ease with which is analyze the relationship between predictors, and an outcome that is dichotomous responses such as the presence or absence of an apnea event [17].

2.6 k-Nearest neighbor

The KNN method is considered as the instance-based classifier, which typically build up and instance of training data and compare new data to the instance using a similarity measure in order to find the best match and make a prediction. KNN is popular density estimation algorithm for numerical data. The density estimation uses a distance measure (usually Euclidean, or Manhattan). For a given distance measure, the only parameter of the algorithm is k, the number of neighbors. The parameter k determines the smoothness of the density estimation: larger values consider more neighbors, and therefore smooth over local characteristics. Smaller values consider only limited neighborhoods. Generally, the choice of k can only be determined empirically [18].

2.7 Decision Tree

The DT paradigm constructs classifiers by dividing the data set into smaller and more uniform groups, based on a measure of disparity or entropy. It does this by identifying a variable and a threshold in the domain of this variable that can be used to divide the data set into two groups. The best choice of variable and threshold is the one that minimizes the disparity measures in the resulting groups. The advantages of DTs over many of the other methods used here is that small DTs can be interpreted by humans as decision rules. Therefore, they offer a way to extract decision rules from a database. This makes them especially well suited for medical applications.

2.8 Support vector machine

SVMs calculates separating hyperplanes that maximize the margin between two sets of data points. By using Lagrange multipliers, the problem can be formulated in such a way that the only operations on the data points are the calculation of scalar products. While the basic training algorithm can only construct linear separators, kernel functions can be used to calculate scalar products in higher dimensional spaces. If the kernel functions are nonlinear, the separating boundary in the original space will be nonlinear. Because there are many different kernel functions, there is a wide variety of possible SVM models. In this study, we applied a single binary SVM classifier with a radial basis function employed as the kernel function. The multiplier coefficient a and regularization parameter c were determined empirically (a = 0.5, c = 1). All classifiers were trained and tested on the classification learner toolbox of MAT-LAB (Mathworks, Inc., Natick, MA, USA).

2.9 Performance analysis

To evaluate the performance of OSA detection, the accuracy (%), sensitivity (%), and positive predictive value (%) were calculated as follows:


where true positive (TP), true negative (TN), false positive (FP), and false negative (FN) refer to the number of events in which normal is classified as normal, normal as abnormal, abnormal as normal, and abnormal as abnormal, respectively. All statistical values were compared between the training and test sets.

3. Experiment Result

Each of the five methods presented above was run on each epoch of the data set of training and test set. Five methods obtained OSA accuracy of 95.2% SVM, 95.2% DT, 95.2% LDA, 94.9% LR, and 93.1% KNN for the training sets, respectively. The performance of the accuracy was shown as 93.2% SVM, 93.2% DT, 93.2% LDA, 92.6% LR, and 90.8% KNN for test sets, respectively (Figure 1).

Three of the five methods (SVM, DT, and LDA) showed the robust performance for the whole dataset. Other two methods (LR and KNN) showed slightly lower results than top three methods. As shown in Table 3, the top three methods detected OSA with the sensitivity and positive predictive value (PPV) were 95.2% and 100% in SVM, 95.2% and 100% in DT, 95.2% and 100% in LDA for the training set, respectively.

As shown in Table 4, the top three methods detected OSA with the sensitivity and PPV and were 93.2% and 100% in SVM, 93.2% and 100% in DT, 93.2% and 100% in LDA for the test set, respectively.

Finding the optimal model for a given OSA classification task depends on not only discriminant power, but also another factors such as cost of model construction and computational power of model. However, we focused on determining the classification performance along and disregarded another two points. Because we used the same dataset for all algorithms, so that the cost of the collecting data is the same for each method. In addition, the rapid advancements in hardware power and CPU speeds are not a problem in shallow learning anymore, so that computational power of the model is not an issue.

Five methods were investigated in this paper, the top three (SVM, DT, and LDA) showed robust classification results, whereas the other two (LR and KNN) drop off considerably on some of the classification task. Even the worst of the five methods achieved sensitivity and PPV values that are comparable to advanced studies [811]. The top three (SVM, DT, and LDA) obtained excellent results above the accuracy of 93%. The results showed relatively good performance even though we used only a heartbeat signal and simple feature sets. The top three methods showed the possibility of accurate OSA detection based on a heartbeat signal.

4. Conclusions

We investigated a simple and accurate method to detect OSA using a heartbeat signal. Only six features were extracted from a heartbeat signal and five different machine-learning methods were compared to find an optimal on the problem of OSA classification. Our results shows the top three classifiers (SVM, DT, and LDA) were with accuracy of 93.2%, 93.2%, and 93.2%, respectively. Top three SVM, DT and LDA classifiers showed strong performance, they could be effective on sleep studies and OSA detections.


This work was supported by the Human Resource Training Program for Regional Innovation and Creativity through the Ministry of Education and National Research Foundation of Korea (No. NRF-2014H1C1A1063845).

Conflict of Interest

No potential conflict of interest relevant to this article was reported.

Fig. 1.

The accuracy of the investigated five methods.


Table 1

OSA patents’ information in detail

Gender (male/female)50/1323/6
Age (yr)57.76±10.5957.54±11.57
BMI (kg/m2)26.37±3.1625.28±2.51
AHI (per hour)31.45±12.5520.85±11.43
Total recording time (min)442.86±38.55441.66±55.41
Total sleep time (min)351.80±76.89346.97±56.78
Sleep efficiency (%)79.55±15.6778.74±9.74

BMI: body mass index, AHI: apnea hypopnea index.

Table 2

The real value of the heartbeat features


Table 3

The results for training set

ClassifiersAccurary (%)Sensitivity (%)PPV (%)

PPV: positive predictive value.

Table 4

The results for test set

ClassifiersAccurary (%)Sensitivity (%)PPV (%)

PPV: positive predictive value.

  1. Patil, SP, Schneider, H, Schwartz, AR, and Smith, PL (2007). Adult obstructive sleep apnea: pathophysiology and diagnosis. Chest. 132, 325-337.
    Pubmed KoreaMed CrossRef
  2. Kapur, V, Strohl, KP, Redline, S, Iber, C, O’Connor, G, and Nieto, J (2002). Underdiagnosis of sleep apnea syndrome in U.S. communities. Sleep Breath. 6, 49-54.
    Pubmed CrossRef
  3. Banno, K, and Kryger, MH (2007). Sleep apnea: clinical investigations in humans. Sleepmedicine. 8, 400-426.
  4. Engleman, HM, and Douglas, NJ (2004). Sleep·4: sleepiness, cognitive function, and quality of life in obstructive sleep apnoea/hypopnoea syndrome. Thorax. 59, 618-622.
    Pubmed KoreaMed CrossRef
  5. Lopez-Jimenez, F, Kuniyoshi, FHS, Gami, A, and Somers, VK (2008). Obstructive sleep apnea: implications for cardiac and vascular disease. Chest. 133, 793-804.
    Pubmed CrossRef
  6. Collop, NA (2002). Scoring variability between polysomnography technologists in different sleep laboratories. Sleepmedicine. 3, 43-47.
  7. Maier, C, and Dickhaus, H (2006). Recurrence analysis of nocturnal heart rate in sleep apnea patients. Biomedizinische Technik. 51, 224-228.
    Pubmed CrossRef
  8. Mendez, MO, Bianchi, AM, Matteucci, M, Cerutti, S, and Penzel, T (2009). Sleep apnea screening by autoregressive models from a single ECG lead. IEEE Transactions on Biomedical Engineering. 56, 2838-2850.
    Pubmed CrossRef
  9. Khandoker, AH, Palaniswami, M, and Karmakar, CK (2009). Support vector machines for automated recognition of obstructive sleep apnea syndrome from ECG recordings. IEEE Transactions on Information Technology in Biomedicine. 13, 37-48.
    Pubmed CrossRef
  10. Xie, B, and Minn, H (2012). Real-time sleep apnea detection by classifier combination. IEEE Transactions on Information Technology in Biomedicine. 16, 469-477.
    Pubmed CrossRef
  11. Varon, C, Caicedo, A, Testelmans, D, Buyse, B, and Van Huffel, S (2015). A novel algorithm for the automatic detection of sleep apnea from single-lead ECG. IEEE Transactions on Biomedical Engineering. 62, 2269-2278.
    Pubmed CrossRef
  12. Chen, L, Zhang, X, and Song, C (2015). An automatic screening approach for obstructive sleep apnea diagnosis based on single-lead electrocardiogram. IEEE Transactions on Automation Science and Engineering. 12, 106-115.
  13. Berry, RB, Brooks, R, Gamaldo, CE, Harding, SM, Lloyd, RM, Marcus, CL, and Vaughn, BV (2015). The AASM manual for the scoring of sleep and associated events. Rules, Terminology and Technical Specifications, Version 2.2. Darien, IL: American Academy of Sleep Medicine
  14. Pan, J, and Tompkins, WJ (1985). A real-time QRS detection algorithm. IEEE Transactions on Biomedical Engineering. 32, 230-236.
    Pubmed CrossRef
  15. Erdenebayar, U, Lee, HK, Kim, H, and Lee, KJ (2014). Sleep apnea detection using a piezo snoring sensor: a pilot study. Journal of Biomedical Engineering Research. 35, 75-80.
  16. Erdenebayar, U, Lee, HK, Kim, H, and Lee, KJ (2014). Sleep apnea detection using a piezo snoring sensor: a pilot study. Journal of Biomedical Engineering Research. 35, 75-80.
  17. Nguyen, HD, Wilkins, B, Cheng, Q, and Benjamin, BA (2014). An online sleep apnea detection method based on recurrence quantification analysis. IEEE Journal of Biomedical and Health Informatics. 18, 1285-1293.
    Pubmed CrossRef
  18. Nguyen, HD, Wilkins, B, Cheng, Q, and Benjamin, BA (2014). An online sleep apnea detection method based on recurrence quantification analysis. IEEE Journal of Biomedical and Health Informatics. 18, 1285-1293.
    Pubmed CrossRef

Erdenebayar Urtnasan received his B.S. in computer science from Huree University, Ulaanbaatar, Mongolia, in 2007 and M.S. in electronic engineering from Inha University, Incheon, Korea, in 2010, respectively. He is currently Ph.D. candidate at Department of Biomedical Engineering, Yonsei University. His current research interestes are sleep signal analysis and machine learning.

Tel: +83-33-760-2808, Fax: +82-33-763-1953, E-mail:

Jong-Uk Park received his B.S. in biomedical engineering from Konyang University, Daejeon, Korea, in 2008 and M.S. in biomedical engineering from Yonsei University, Wonju, Korea, in 2012, respectively. He is currently Ph.D. candidate at Department of Biomedical Engineering, Yonsei University. He has been working on research related to sleep signal analysis, algorithm development and signal processing.

Tel: +83-33-760-2808, Fax: +82-33-763-1953, E-mail:

SooYong Lee received his Ph.D. in mathematics from the Kyunghee University, Seoul, Korea, in 1992. He also received his Ph.D in computer science fron the Yonsei University, Seoul, Korea, in 2004. He is a faculty member at Yonsei University, Wonju, Korea since 2004. He has been working on research related to artificial intelligence, fuzzy logic, machine learning and data mining.

Tel: +83-33-760-2270, Fax: +82-33-763-1953, E-mail:

Kyoung-Joung Lee received his B.S., M.S., and Ph.D. in electric engineering from the Yonsei University, Seoul, Korea, in 1981, 1983, and 1988, respectively. He was an international fellow at Case Western Reserve University, USA, in 1993. He joined Yonsei University, Wonju, Korea, as a faculty member in 1989. His research interests include medical instrument, biosignal processing and biosystem modelling.

Tel: +83-33-760-2433, Fax: +82-33-763-1953, E-mail: