# Real-Time Psychological Stress Detection According to ECG Using Deep Learning
## 3 Results
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Algorithms** & **Accuracy** & **Recall** & **Specificity** \\ \hline XGboost & 0.637 & 0.492 & 0.765 \\ Logistic & 0.614 & 0.462 & 0.760 \\ LinearSVM & 0.624 & 0.468 & 0.748 \\ Randomforest & 0.502 & 0.424 & 0.708 \\ Decision Tree & 0.482 & 0.407 & 0.694 \\ Bayes & 0.459 & 0.497 & 0.741 \\ Gauss SVM & 0.632 & 0.492 & 0.747 \\ KNN & 0.575 & 0.483 & 0.755 \\ Adaboost & 0.547 & 0.393 & 0.667 \\ Average & 0.563 & 0.457 & 0.731 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: The accuracy and recall of conventional method on 10 s ECG. Figure 14: The confusion matrix of XGboost. Based on the fixed optimal conv filter number, other experiments were conducted, and a similar phenomenon could also be observed in the experiment of BiLSTM size. In the experiment of BiLSTM size, as shown in Figure 17, the accuracy is not increased at the size of 64 compared with the size of 32. However, the time for training did greatly increase. Considering the accuracy and training time, 32 BiLSTM units were used for the proposed network. Figure 16: The relation of filter number and learning accuracy and learning loss. Figure 15: The Receiver Operating Characteristic (ROC) Curve of XGBoost  
The size of pooling window and \(n\)-inputs of BiLSTM was determined based on the maximum accuracy. As shown in Figure 18, the proposed network achieved the highest accuracy when the pool length was set to 8. The set implies that for the features generated by the convolutional layer, the pooling layer will downsample using a window of size 8. As shown in Figure 19, the proposed network achieved the highest accuracy when the \(n\)_input was set to 50. The set implies that BiLSTM could further extract more abstractive features from each 50 initial features that CNN was able to extract. Figure 17: The relation of LSTM size and learning accuracy and learning loss. Figure 18: The relation of pool length and learning accuracy and learning loss. To reduce training time without affecting the performance of the proposed network, we also attempted to reduce redundant features and save training time by adjusting the size of the stride in the pooling layer. At the beginning, we set the size of the stride to 2. This implies that there will be 0.5 times features that the Conv layer extracted when inputting to the BiLSTM layer. As seen in Figure 20, until the stride size increased to 8, the accuracy of the model began to decline, which implies that the size of 8 could filter out redundant features to the maximum. Finally, for the outputs of BiLSTM, we tried three stitching methods based on the previously obtained optimization parameters. As shown in Figure 21, the method of addition which was adopted by the proposed network obtained the highest accuracy. Figure 19: The relation of input size and learning accuracy and learning loss. Figure 20: The relation of stride size and learning accuracy and learning loss. The proposed network obtained the accuracy of 0.865, and a specificity of 0.928. Compared to the conventional methods (XGboost), our proposed network improves accuracy by 0.228. The ROC curves of the proposed network and the XGBoost are as shown in Figures 15 and 22, the area under the curve (AUC) in moderate stress was 0.88 improved by 0.1 compared with XGboost's, the AUC in high stress was 0.85 improved by 0.17. The confusion matrix of the proposed network was as shown in Figure 23, the recall of low stress was 0.913, the recall of moderate stress was 0.894, and the recall of high stress was 0.798. It could thus be concluded that the proposed network produces a significant increase in the classification of the stress on three levels compared to the conventional methods. Figure 21: The relation of stitching methods and learning accuracy and learning loss. Figure 22: The curve of the proposed network.