## 4 Experimentation and Results
### Experiment 2: How Well SAFEPA Performs in the Facial Expression Recognition Task  
Of all the models for the case of FER, in Experiment 2, we explore how well the SAFEPA model can be extended to recognize facial expressions. We first provide a comparison and analysis of all models for the case of FER, restricting our datasets to full frontal face images. Although such a restriction will limit us in showing all the potentials of SAFEPA, it will demonstrate it to be compatible with the state -of-the-art models for FER, even in the restricted cases. We then present the results showing the SAFEPA's ability to outperform the models in [17] when various facial poses are present utilizing a subset of the KDEF dataset (consisting of 3920 samples) that excludes the frontal view, as well as the complete KDEF dataset (4900 samples). To do this, we trained the SAFEPA on a subset of the KDEF \begin{table}
\begin{tabular}{c c c} \hline \hline
**The Model** & **Input Size** & **Accuracy \%** \\ \hline VGG16 [17] & \(300\times 300\) & 52.57 \\ VGG16 [17] & \(150\times 150\) & 55.25 \\ ResNet50 [17] & \(300\times 300\) & 51.06 \\ ResNet50 [17] & \(150\times 150\) & 44.29 \\ Ensemble [17] & \(300\times 300\) & 75.23 \\ Ensemble [17] & \(150\times 150\) & 75.52 \\ [PERSON] and [PERSON] [3] & \(128\times 128\) & 94.00 \\ [PERSON], et al. [22] & \(224\times 224\) & 90.50 \\ [PERSON] and [PERSON] [23] & \(128\times 128\) & 96.00 \\ SAFEPA & \(150\times 150\) & 98.93 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Comparison of 10-fold cross-validation accuracies obtained from running models in [17], executing SAFEPA, and three recent studies focused on pain assessment, all performed on a subset of the UNBC-McMaster dataset. Figure 10: The ROC curve for the best performing model: 10-fold cross-validation of SAFEPA on UNBC-McMaster dataset. Figure 9: Confusion matrix for the best performing model: 10-fold cross-validation of SAFEPA on UNBC-McMaster dataset. dataset consisting of 980 samples with frontal faces and an input size of 150 \(\times\) 150. The model was trained using the Stochastic Gradient Descent (SGD) optimizer with a batch size of 32 for 50 epochs. The 10-fold cross-validation results show that the SAFEPA model achieved a competitive accuracy of 97.94%. These results are particularly noteworthy when compared to those obtained in [17, 24, 26], where VGG16 and Ensemble were used to extract features from the same subsets of KDEF but with an image size of 300 \(\times\) 300 and trained for 500 epochs. The results of the experiment are summarized in Table 3.  
We also sought to evaluate the performance of the SAFEPA and models described in [17] on facial expression recognition (FER) under different poses, including full left and right profiles. To execute this, we trained the models in [17] on a subset of the KDEF dataset (consisting of 3920 samples) that excludes the frontal view, as well as the complete KDEF dataset (4900 samples) using the same approach as described in Experiment 1, but without the face detection step, which is not applicable for full left and right profiles. In contrast, the SAFEPA model was trained specifically for FER on the same subset of 3920 samples of KDEF and on the whole KDEF dataset, utilizing an ADAM optimizer and a batch size of 32 for 75 epochs. The input size was set to 150 \(\times\) 150. For 10-fold cross-validation, the SAFEPA achieved the highest performance with a 95.51% accuracy on the subset of 3920 samples of KDEF and 94.29% on the entire KDEF outperforming the other models. We conducted a follow-up experiment on the subset of KDEF with 980 samples, using 70% of the data for training and 30% for testing as in [25], with the same parameters as Experiment 2. SAFEPA achieved an accuracy of 84.19%, which is superior to the accuracy obtained by the model presented in [25], which employed HOG for feature extraction and SVM for classification. The results are presented in Table 4.  
The performance of the SAFEPA model was evaluated on a 30% test set from the subset of KDEF (980) dataset.