Sleep stage classification, including wakefulness (W), rapid eye movement (REM), and non- rapid eye movement (NREM) which includes three sleep stages that describe the depth of sleep, is one of the most critical steps in effective diagnosis and treatment of sleep-related disorders. Clinically, sleep staging is performed by domain experts through visual inspection of polysomnography (PSG) recordings, which is time-consuming, labor-intensive and often subjective in nature. Therefore, this study develops an automatic sleep staging system, which uses single channel electroencephalogram (EEG) signal, for convenience of wearing and less interference in the sleep, to do automatic identification of various sleep stages. To achieve the automatic sleep staging system, this study proposes a two-layer stacked ensemble model, which combines the advantages of random forest (RF) and LightGBM (LGB), where RF focuses on reducing the variance of the proposed model while LGB focuses on reducing the bias of the proposed model. Particularly, the proposed model introduces a class balance strategy to improve the N1 stage recognition rate. In order to evaluate the performance of the proposed model, experiments are performed on two datasets, including Sleep-EDF database (SEDFDB) and Sleep-EDF Expanded database (SEDFEDB). In the SEDFDB, the overall accuracy (ACC), weight F1-score (WF1), Cohen’s Kappa coefficient (Kappa), sensitivity of N1 (SEN-N1) obtained by proposed model are 91.2%, 0.916, 0.864 and 72.52% respectively using subject-non-independent test (SNT). In parallel, the ACC, WF1, Kappa, SEN-N1 obtained by proposed model are 82.4%, 0.751, 0.719 and 27.15% respectively using subject-independent test (SIT). Experimental results show that the performance of the proposed model are competitive with the state-of-the-art methods and results, and the recognition rate of N1 stage is significantly improved. Moreover, in the SEDFEDB, the experimental results indicate the robustness and generality of the proposed model.