# Hybrid Deep Learning Approach for Automated Sleep Cycle Analysis
## 1 Introduction
\begin{table}
\begin{tabular}{p{42.7 pt} p{284.5 pt}} \hline \hline
**Sleep Stage** & **Classification Criteria** \\ \hline \multirow{4}{*}{W} & This stage represents an alert state with high-level activity in the brain. EEG recordings display alpha waves (8–13 Hz, 20–40 \(\mu\)V), commonly related to relaxation, and beta waves (13–30 Hz, 10–30 \(\mu\)V), linked to cognitive and physical activity. \\ \hline \multirow{4}{*}{R} & This stage is characterized by rapid eye movement beneath closed eyelids. The EEG exhibits a low-amplitude mix of theta and delta waves (2–7 Hz), and EMG activity in the chin decreases, leading to temporary muscle paralysis. During this stage, memory consolidation and emotional processing occur. Furthermore, REM sleep cycles last between 5 and 30 min per occurrence. \\ \hline \multirow{4}{*}{S1} & This is an intermediate stage from wakefulness to sleep. It is defined by a decrease in alpha waves below 50\% of the epoch, an increase in theta and delta waves (2–7 Hz), and slow rolling eye movements observed in EOG. This stage usually lasts between 5 and 10 min. \\ \hline \multirow{4}{*}{S2} & This stage represents roughly 50\% of the overall sleep duration and is classified as light sleep. It is characterized by the predominant theta activity (>75 \(\mu\)V, <2 Hz), including both sleep spindles and K-complex patterns (>0.5 s), along with a notable decrease in both muscular engagement and eye activity. \\ \hline \multirow{4}{*}{S3} & In this stage, deep sleep begins, with the predominance of delta waves (1–3 Hz, >75 \(\mu\)V) of less than 50\% of the epochs, although spindle bursts and K-complex waveforms can still appear. During this stage, physical and mental recovery processes take place. \\ \hline \multirow{4}{*}{S4} & Also classified as deep sleep, this stage is predominantly composed of delta waves. Cardiac and respiratory rates decrease to their lowest levels, supporting immune function and muscle restoration. \\ \cline{1-1}  & \\ \cline{1-1}  & \\ \cline{1-1}  & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: R&K rules for sleep stage classification. Figure 3: First five seconds of an EEG recording decomposed into frequency bands. and S2 were changed to N1 and N2, respectively. Furthermore, the wakefulness stage was renamed wake [18,19]. This research presents a deep neural network framework for the classification of sleep stages using EEG data. Following the AASM guidelines, the classification targets the five main sleep stages: W, R, N1, N2, and N3. To address class imbalance, random undersampling at the epoch level is applied. The proposed architecture integrates convolutional neural networks (CNN) and bidirectional long short-term memory (BiLSTM) networks, further enhanced by an attention mechanism. This approach aims to eliminate the need for hand-crafted feature design and to enable the processing of extensive amounts of EEG data. The methodology follows a structured pipeline consisting of five key steps: data acquisition and preprocessing, data splitting, class balancing, model training, and performance evaluation. Initially, EEG signals are obtained from PSG data along with the corresponding annotations from hypnogram (HYP) files. The signals then undergo preprocessing steps. Subsequently, the dataset is randomly partitioned into training, validation, and testing subsets. To address class imbalance, this work proposes an epoch-level random undersampling (E-LRUS) technique, applied to the training and validation sets. In the model training phase, deep learning architectures, specifically CNNs in combination with BiLSTM, are implemented to learn features directly from the EEG signals. In addition, an attention mechanism is integrated into the architecture to assign varying importance to different time steps. Finally, the trained models are evaluated using standard machine learning metrics to assess the classification performance.