# Seizure Detection in Medical IoT: Hybrid CNN-LSTM-GRU Model with Data Balancing and XAI Integration
## 2 Materials and Methods  
Recently, considerable focus has been placed on the classification and modeling of EEG data. Electroencephalography (EEG) has become an essential tool for remote epileptic seizure detection, and numerous methodologies have been developed for the early assessment of epilepsy [9; 10; 11]. Recent research has focused on optimizing EEG data classification and enhancing privacy through secure methods. [PERSON] and colleagues [9] proposed a Sparse Group Representation Model (SGRM) that leverages intersubjective data to develop an accurate motor imagery-based Brain-Computer Interface (BCI), achieving a classification accuracy of 78.2%. [PERSON] and colleagues [10] utilized the Fuzzy Discernibility Matrix (FDM) for feature extraction from EEG signals, employing Support Vector Machine (SVM) and ensemble classifiers for accuracy evaluation, though the method encounters limitations in handling large EEG datasets and multiclass scenarios. For EEG data classification, a deep Convolutional Neural Network (CNN) approach reached 86.41% accuracy in [11] and 85.62% in [12]. In another study, Coiflets wavelets were used for preprocessing, focusing on amplitude-based feature extraction [13]. [PERSON] and colleagues [14] applied Joint Factor Analysis and I-vectors for feature extraction with Universal Background Models (UBMs) for classification, although this approach did not achieve optimal accuracy. In [15], multi-feature fusion with CNNs was recommended for automated epilepsy detection. Another study [16] proposed an algorithm for noisy environments, using sample entropy and phase synchronization with Variational Mode Decomposition (VMD) for seizure detection. This model emphasized minimizing false alarms while ensuring cross-patient applicability. To improve efficiency, the dynamic Epileptic-Net model was introduced [17], and in [18], both time- and frequency-domain features were used with machine learning models (e.g., Logistic Regression, Decision Trees, SVM) to detect seizures within the Temple University Hospital (TUH) corpus. Additionally, Ref. [19] used discrete wavelet transform (DWT) and genetic algorithms with machine learning classifiers to enhance epileptic seizure detection accuracy and reduce computation time. Additionally, in [20], a novel method integrating Bi-LSTM, GRU, and Average Pooling demonstrated exceptional performance across binary and multiclass tasks. Also, some hybrid models are used as in [21; 22; 23]. One of the open research areas in AI and ML is XAI. Although AI, especially deep learning, has become increasingly sophisticated and complex, they are viewed as \"black boxes\", making it difficult to understand how they compute the predictions or decisions. XAI provides the tools to explain and interpret these models in users appropriate ways to trust the models [24; 25; 26]. In the last decade there has been a lot of research focus into XAI in healthcare [27]. In Ref. [28] the revolutionary potential of Explainable AI (XAI) is demonstrated in developing Healthcare 5.0. It highlights the significance of explainability in boosting trust, privacy, and clinical decision-making by proposing a thorough architecture and solution taxonomy for XAI in applications like CT image analysis and ECG monitoring. Recently, considerable research has focused on EEG classification, as demonstrated by the studies discussed above. Table 1 shows a comparative summary of EEG data classification techniques in medical applications. However, little attention has been paid to applying optimization techniques to improve machine learning models and address the problem of imbalanced data in seizure recognition datasets. These datasets are used to classify EEG signals and aim to automatically detect seizures at an early stage. This paper presents an effective approach for seizure detection and prediction that not only addresses the problem of imbalanced EEG data, which often leads to overfitting, but also incorporates optimization techniques to improve model performance.