## 2 Materials and Methods
### Methodology
#### 2.2.3 Training and Evaluation  
Comparative supervised classification was carried out with four classifiers: random forest (RF), gradient-boosting decision tree (GBDT), support vector machine (SVM), and k-nearest neighbors (k-NN). The four classifiers were chosen based on findings from previous studies, which showed that they had superior classification compared to others [15; 26; 27; 43; 44] The random forest algorithm, an ensemble learning method, involves multiple un-pruned decision tree classifiers. Every tree is an individual classifier, built at the training stage using randomly selected attributes from the original data and at each node to determine the best split. Classification is determined based on majority voting [45]. The gradient-boosting decision tree classifier runs an iterative algorithm to build multiple trees sequentially, where each tree learns and updates its model from the errors of all preceding ones [46]. The support vector machine, an extensively adopted supervised learning classifier, has been widely and successfully used in EEG binary classification problems and specifically in the medical field (automatic seizure detection, mental task classification, epileptic EEG classification, emotion recognition, etc.). The k-nearest neighbors algorithm assigns an unlabeled sample to the most frequently occurring class among the k-nearest labeled training samples. The Euclidean distance is used as the distance metric for k-NN [47].  
These proposed ML techniques are based on the most widely used algorithms in previous studies and in various classification problems, as these algorithms have better predictive power and are designed to perform better than linear algorithms, especially for complex non-linearly separable EEG data. Additionally, these techniques have the great advantage of having fewer parameters and hyper-parameters, which makes optimization easier. The model was developed with a view toward being sufficiently transferable to enable the integration in the connected objects for real-time detection.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Type** & **Features** & **Category** \\ \hline \multirow{6}{*}{Complexity measures} & Sample entropy & \\  & Logarithmic entropy & \\  & Wavelet entropy & \\  & Spectral entropy & \\  & Shannon entropy & \\  & Permutation entropy & \\ \hline \multirow{2}{*}{Oscillatory power} & Absolute power relative power & \\  & (delta, theta, alpha, beta, gamma) & Frequency domain \\ \hline \hline \end{tabular}
\end{table}
Table 2: Subset of features in correspondence to their category.  
To avoid overfitting, for each experiment, the dataset was partitioned randomly into training and testing portions, using 10-fold cross-validation repeated 100 times so that one-fold served for testing and the remaining k-1 folds were used for training. The parameter settings of the classifiers in all experiments were as follows: for RF, the number of trees was 100, for GBDT it was 100 as well, for SVM the kernel type was linear, and for k-NN the number of nearest neighbors was 5.  
To handle imbalanced data, which may occur due to uneven data representation of classes in the training dataset, with a ratio of seizure to seizure-free of approximately 1:4, we corrected the weights of minority and majority classes according to the distribution of the classes in the entire training set. Furthermore, the weights were inversely proportional to the frequency of classes in the dataset. In a final step, the accuracy and the area under the curve (AUC), an effective metric that combines sensitivity and specificity for classification performance evaluation, were computed for each subset of features and also for the entire set. An F-measure representing the harmonic mean of precision and recall was used as well to study performance. For clarity, results are given per 20 s window size input vector and with respect to the three set of features: complexity, power, and a combination of the two. We compared the results with and without the feature selection step.