# Seizure Detection in Medical IoT: Hybrid CNN-LSTM-GRU Model with Data Balancing and XAI Integration
* **Layer 3:** The utilization of cloud computing comes into play here, demonstrating its efficiency in powering intelligent medical IoT systems. The proposed system employs cloud computing servers for the storage and processing of industrial control field data obtained through the MIoT-based controller. The collected medical data are periodically transmitted to the appropriate channel via an IoT protocol like the Constrained Application Protocol (CoAP). * **Layer 4:** At this layer, the focus shifts towards crafting mobile and web applications that interface with cloud servers to access analytical outcomes generated by applying machine learning techniques to store medical and healthcare data. The primary objective is to provide actionable decision-making insights for healthcare institutions. In general, the multitier architecture of an MIoT system facilitates seamless data flow, storage, and subsequent analysis. Imbalanced data pose a significant challenge in EEG seizure detection, where it refers to an unequal distribution of instances across classes in the dataset. In EEG seizure detection, instances representing normal brain activity typically far exceed those depicting seizure events. This imbalance can result in biased model performance and inaccurate predictions, as the algorithm may favor the majority class (normal activity) while struggling to accurately identify the minority class (seizures). Imbalanced data in EEG seizure detection can have significant consequences. Models trained on imbalanced datasets often default to classifying most instances as belonging to the majority class (normal brain activity) due to its prevalence, thereby overlooking the critical minority class (seizures). This leads to a problematic trade-off where the model's high accuracy is largely due to its success in identifying the majority class, while it struggles to detect seizure events accurately. Addressing imbalanced data in EEG seizure detection is essential for achieving accurate and reliable outcomes. Techniques like resampling--either by oversampling the minority class or under-sampling the majority class creating synthetic samples--and specialized algorithms such as ensemble methods can help balance class distributions. These approaches enable the model to effectively learn from both classes, ensuring that seizure instances are not overshadowed by the abundance of normal data, thus improving the overall performance and reliability of seizure detection. Figure 1: A typical medical IoT (MIoT) model. In real-world scenarios, collecting medical data like EEG from devices poses additional challenges, often resulting in a class imbalance that complicates fault diagnosis. Training seizure detection models directly on such imbalanced datasets can lead to overfitting on the minority class and bias toward the majority class. To overcome this, we propose a specialized seizure detection framework, leveraging an optimized K-Nearest Neighbors (KNN) algorithm adapted for imbalanced EEG data, specifically designed to enhance performance in smart medical IoT systems. In brief, this paper provides a robust and intelligent framework for seizure detection considering the context of MIoT devices. With the impressive strides seen in MIoT health care, we emphasize the relevance and practicality of our ensemble model in this field. The contributions of this paper can be summarized as follows:  
* The proposed hybrid framework is a merge of deep learning techniques including Convolutional Neural Networks (CNNs), Long Short-Term Memory (LSTM) networks, and Gated Recurrent Units (GRUs) The suggested hybrid framework is validated for seizure detection in EEG signals. * The synthetic minority oversampling technique (SMOTE) is applied and is used to balance the dataset by creating additional samples for the minority class. Additionally, the Explainable Artificial Intelligence (XAI) technique, SHAP (Shapley Additive Explanations), is applied to evaluate the importance and effectiveness of the features.