Table of Content

Open Access iconOpen Access



Automatic Sleep Staging Algorithm Based on Random Forest and Hidden Markov Model

Junbiao Liu1, 6, Duanpo Wu2, 3, Zimeng Wang2, Xinyu Jin1, *, Fang Dong4, Lurong Jiang5, Chenyi Cai6

1 College of Information Science & Electronic Engineering, Zhejiang University, Hangzhou, China.
2 School of Communication Engineering, Hangzhou Dianzi University, Hangzhou, China.
3 Zhejiang Provincial Key Laboratory of Information Processing, Communication and Networking, Hangzhou, China.
4 College of Information and Electric Engineering, Zhejiang University City College, Hangzhou, China.
5 School of Information Science and Technology, Zhejiang Sci-Tech University, Hangzhou, China.
6 Hangzhou Neuro Science and Technology Co., Ltd., Hangzhou, China.

∗ Corresponding Author: Xinyu Jin. Email: email.

(This article belongs to the Special Issue: Computer Methods in Bio-mechanics and Biomedical Engineering)

Computer Modeling in Engineering & Sciences 2020, 123(1), 401-426.


In the field of medical informatics, sleep staging is a challenging and timeconsuming task undertaken by sleep experts. According to the new standard of the American Academy of Sleep Medicine (AASM), the stages of sleep are divided into wakefulness (W), rapid eye movement (REM) and non-rapid eye movement (NREM) which includes three sleep stages (N1, N2 and N3) that describe the depth of sleep. This study aims to establish an automatic sleep staging algorithm based on the improved weighted random forest (WRF) and Hidden Markov Model (HMM) using only the features extracted from double-channel EEG signals. The WRF classification model focuses on reducing the bias of the imbalance data, while the HMM model focuses on improving the detection rate of sleep staging through the relationship between adjacent sleep stages. In particular, the improved weighted RF classification model can increase the recognition rate of the N1 stage. In addition, the method of removing features with low variance is used to select meaningful and contributing feature parameters for model training. This is an innovative content of this paper. The sleep EEG data are first segmented into 30 s epochs, and the feature parameters of the epoch data are extracted from the double-channel by applying continuous wavelet packet transform (WPT). Each epoch is then segmented into 29 subepochs of 2 s long with 1 s overlap, and the frequency domain features and statistical features of each subepoch are extracted. The performance of the proposed method is tested by evaluating the accuracy (AC), Kappa coefficient, Recall (R), Precision (P) and F1-score (F1). In the Sleep-EDF database, the overall AC and Kappa coefficient obtained by WRF are 93.20% and 0.890, respectively using the subject-non-independent test. In the 10 sc* and 10 st* Sleep-EDF Expanded database, the overall AC and Kappa coefficient obtained by proposed method are 91.97% and 0.874, respectively using the subject-independent test. The best AC and Kappa coefficient of single subject can reach 96.3% and 0.912, respectively. Experimental results show that the performance of the proposed method is competitive with the most current methods and results, and the recognition rate of N1 stage is significantly improved.


Cite This Article

APA Style
Liu, J., Wu, D., Wang, Z., Jin, X., Dong, F. et al. (2020). Automatic sleep staging algorithm based on random forest and hidden markov model. Computer Modeling in Engineering & Sciences, 123(1), 401-426.
Vancouver Style
Liu J, Wu D, Wang Z, Jin X, Dong F, Jiang L, et al. Automatic sleep staging algorithm based on random forest and hidden markov model. Comput Model Eng Sci. 2020;123(1):401-426
IEEE Style
J. Liu et al., "Automatic Sleep Staging Algorithm Based on Random Forest and Hidden Markov Model," Comput. Model. Eng. Sci., vol. 123, no. 1, pp. 401-426. 2020.


cc This work is licensed under a Creative Commons Attribution 4.0 International License , which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.
  • 4082


  • 2916


  • 0


Share Link