# A Hybrid CNN-GRU-LSTM Algorithm with SHAP-Based Interpretability for EEG-Based ADHD Diagnosis
## 3 Materials and Methods
### Rationale for Method Selection
In parallel, an alternative convolutional stream processes the input using a series of cascading Conv1D blocks with subsequent batch normalization and MaxPooling1D for the derivation of powerful and hierarchically abstract spatial information. The outputs from the two branches are merged and fed into a dense layer coupled with batch normalization and dropout, which improves generalization and reduces overfitting. The composite structure is a denser spatiotemporal learning approach, positioning the model to achieve improved performance in classifying complex EEG patterns. Figure 4: Hybrid CNN-LSTM model for EEG classification. Figure 6 illustrates the architecture of the transformer encoder (2\(\times\) blocks) model developed for EEG-based ADHD classification. The model begins with an input layer of shape (None, 19, 1), representing 19 EEG channels, which are projected into a 32-dimensional embedding space using a dense layer. Positional encoding is then applied to preserve the spatial structure of electrode placements. The core of the model consists of two sequential transformer encoder blocks, each incorporating multi-head self-attention and feed-forward sublayers to capture spatial dependencies between EEG channels. A GlobalAveragePooling1D layer aggregates the features across channels, followed by a dense layer with 64 units (ReLU activation) and a dropout layer (rate = 0.3) to prevent overfitting. The final output is generated by a sigmoid-activated dense layer, producing a probability score for binary ADHD classification. Figure 7 illustrates the architecture of the transformer encoder (3\(\times\) blocks) model, which builds upon the encoder-only transformer design to enhance feature representation for EEG-based ADHD classification. The model takes EEG input in the shape (None, 19, 1), corresponding to 19 spatial channels, and projects it into a 32-dimensional embedding space using a dense layer. Positional encoding is applied to retain the spatial order of EEG electrodes, crucial for capturing cortical topography. The core component includes three stacked transformer encoder blocks, enabling deeper learning of spatial relationships and multiscale dependencies across EEG channels. A GlobalAveragePooling1D layer condenses the sequence of learned embeddings into a fixed-size vector, which is further processed through a dense layer (64 units, ReLU activation) and dropout (rate = 0.3) to reduce overfitting. The final dense layer with sigmoid activation outputs the classification probability, distinguishing between ADHD and control cases. Figure 5: CNN-GRU-LSTM model architecture for EEG classification. implicit temporal dependencies across EEG channels. The input has the shape (None, 19, 1), corresponding to 19 EEG electrodes, and is first projected into a 32-dimensional feature space using a dense layer. A two-dimensional positional encoding mechanism is then applied to preserve spatial electrode topology and potential temporal ordering, enhancing the contextual representation of EEG signals. This enriched sequence is passed through three stacked transformer encoder blocks, each employing multi-head self-attention to capture nonlinear interchannel interactions and hierarchical dependencies. The sequence output is condensed using a GlobalAveragePooling1D layer, followed by a dense layer with 64 units and ReLU activation. A dropout layer (rate = 0.3) is applied for regularization. The final dense layer with sigmoid activation generates the output probability for binary classification between the ADHD and control classes. Figure 9 illustrates the architecture of the proposed hybrid CNN-RNN-transformer model for EEG-based ADHD classification. This hybrid model combines three distinct processing branches to capture diverse aspects of EEG data. The CNN branch employs a series of Conv1D layers with increasing filter sizes (\(32\to 256\)), interleaved with MaxPooling, batch normalization, and dropout, to extract robust local spatial features across multiple frequency bands.