## 3 Experimental Set-Up
### Training Details  
The models were trained using 5-fold cross-validation (80% training, 20% testing), with ACC as the primary performance measure. In addition, the best-performing fold was selected for each model and subject to generate the most representative FCAMs (see Section 2.3). We employ the Scikit-Learn, MNE, and TensorFlow Python libraries. All  
Figure 4: This analysis includes 22 features per subject, incorporating demographic information (Age and Sex), subject-specific performance metrics (Accuracy, Cohen’s Kappa, and AUC) for FB-CSP, EEGNet, and KCS-FCnet, along with their standard deviations. Additionally, functional connectivity statistics derived from KCS-FCnet, such as entropy and \(p\)-value, are also included. experiments were conducted in a Kaggle notebook using the 2022-10-20 environment, which provides two Tesla T4 GPUs with 15 GB of VRAM, 30 GB of RAM, and an Intel Xeon CPU @ 2G Hz with two threads per core and two sockets per core. We trained the DL methods for 500 epochs using the Adam optimizer (\(1\times 10^{-3}\) learning rate) and binary cross-entropy loss. Additionally, we implemented callbacks to terminate training upon encountering NaN values and to reduce the learning rate when training plateaued. For hyperparameter selection, we used grid search, varying the \(\Delta_{T}\) value as \(\frac{F_{S}}{2}\), \(\frac{F_{S}}{4}\), and \(\frac{F_{S}}{10}\), and setting the number of filters for KCS-FCnet to 2, 4, or 8. The kernel bandwidth in Equation (4) is tuned through gradient descent within KCS-FCnet training, taking as reference the median pairwise channel EEG Euclidean distances. Additionally, EEGNet, DeepConvNet, ShallowConvNet, and TCFusionNet are trained using their respective predefined hyperparameters. Table 2 summarizes the DL hyperparameters used, with any unspecified values set to TensorFlow's defaults. Also, Table 3 details the architecture of the KCS-FCnet. All Python codes are publicly available at [[https://github.com/sbuitragoo/master-thesis/tree/main/code](https://github.com/sbuitragoo/master-thesis/tree/main/code)]([https://github.com/sbuitragoo/master-thesis/tree/main/code](https://github.com/sbuitragoo/master-thesis/tree/main/code)) (accessed on 1 December 2024). For subject-dependent training, each model was independently trained and evaluated using data from individual subjects. This approach highlights the importance of capturing subject-specific pain mechanisms, which can inform more personalized treatment strategies--ultimately improving the likelihood of therapeutic success [50]. Subsequently, to assess whether the tested pain detection approaches can achieve a suitable cross-subject generalization, the presented approach in Section 2.4 is carried out for visual subject stratification and grouping. Then, a Leave-One-Subject-Out (LOSO) cross-validation strategy \begin{table}
\begin{tabular}{c c c} \hline \hline
**Training Hyperparameter** & **Argument** & **Value** \\ \hline \multirow{4}{*}{Reduce learning rate on plateau} & Monitor & Training Loss \\  & Factor & 0.1 \\  & Patience & 30 \\  & Min Delta & 0.01 \\  & Min Learning Rate & 0 \\ \hline Adam & Learning Rate & 0.1 \\ \hline \multirow{2}{*}{Stratified Shuffle Split} & Splits & 5 \\  & Test Size & 0.2 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Deep learning hyperparameter setting.