# Sleep Apnea Classification Using the Mean Euler-Poincare Characteristic and AI Techniques
## 5 Results and Discussion  
A machine learning model was developed to detect cases of sleep apnea using an ensemble K-nearest neighbors (KNN) classifier. The first phase of the study involved training the model using a dataset that included 20 cases of severe sleep apnea (1 h of activity), 5 mild cases (\(<\)1 h), and 10 cases with non-apnea. The results of this phase are presented in the form of a confusion matrix, as shown in Figure 10. The model's accuracy was found to be 80%. Also, we found a sensitivity of 82% and a specificity of 71%. To achieve these results, we used the following formulas using the results of the confusion matrix:  
\[Accuracy=(TP+TN)/(P+N)=(23+5)/(35)\times(100\%)=80\%\]  
\[Sensitivity=(TP)/(TP+FN)=(23)/(23+5)\times(100\%)=82\%\]  
\[Specificity=(TN)/(TN+FP)=(5)(5+2)\times(100\%)=71\%\]  
where \(P\) and \(N\) represent positive and negative cases, respectively; \(TP\) and \(TN\) denote true positives and true negatives; and \(FP\) and \(FN\) represent false positives and false negatives. Figure 10 shows the total correct predictions of the trained model, where it achieved 92% accuracy in apnea cases and 50% accuracy in non-apnea cases. In this work, we used 15 th- and 21 st-order polynomials to soften the signal, but the model achieved the same results obtained with the training data; Figure 10 expresses the results for the two polynomial orders in this phase. Figure 10: Confusion matrix for the training phase using 15 th- and 21 st-order polynomials. Both cases had the same results. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter** & **Description** & **Value** \\ \hline
**Input Layer** & Number of input features & 101 (from EPC model) \\ \hline
**Hidden Layers** & Number of hidden layers & 2 \\ \hline
**Neurons** & Number of neurons per layer & 100 (Layer 1), 64 (Layer 2), 64 (Layer 3) \\ \hline
**Output Layer** & Number of neurons in output layer & 1 \\ \hline
**Activation Functions** & Activation function per layer & Swish (Layer 1), ReLU (Layer 2), \\  & & Tanh (Layer 3), Softmax (Output Layer) \\ \hline
**Optimizer** & Optimization algorithm & Adam \\ \hline
**Epochs** & Number of epochs & 100 \\ \hline
**Classes** & Number of output classes & 2 (binary classification) \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Summary of feedforward multi-layer neural network parameters. In the testing phase, we used the validation data to obtain the results presented in Figures 11 and 12; one set of results uses a 15 th-order polynomial and the other uses a 21 st-order polynomial. Figure 11 shows that patients with apnea were correctly classified 100% of the time, while those without apnea were correctly classified 88% of the time. In addition, the accuracy, sensitivity, and specificity were calculated with the above-mentioned formulas, yielding results of 97%, 96%, and 100%, respectively. Figure 12 shows the results using the 21 st-order polynomial, where the patients with apnea were correctly classified 100% of the time, and those without apnea were correctly classified 75% of the time. Additionally, the accuracy, sensitivity, and specificity were calculated using the formulas mentioned above, yielding results of 94%, 93%, and 100%, respectively. A new method for classifying sleep apnea is proposed, which involves performing a geometric transformation and extracting information through the Euler-Poincare characteristic model from Holter ECG and one lead (lead \(V_{3}\)). Using a 15 th-order polynomial in the pre-processing phase, the model achieves an average accuracy of 89%, a sensitivity of 89%, and a specificity of 86%. The results obtained with the feedforward neural network are presented for the training phase in Figure 13 and for the test phase in Figure 14. The summary of these results is shown in Table 4.  
Figure 11: Results of the confusion matrix for the validated data using a 15 th-order polynomial. Figure 12: Results for the test phase using a 21 st-order polynomial. The FNN has a better response than the EKNN.