# A Stray Light Detection Model for VR Head-Mounted Display Based on Visual Perception
## 4 Modeling
The outputs were the records if the observer perceived the stray light and were labelled 0 when there was no stray light. In contrast, they were labelled as 1 to express that the stray light was present. As a consequence, the task was regarded as a binary classification problem. Four supervised learning algorithms, including K-Nearest Neighbor (KNN), Logistic Regression (LR), Support Vector Machine (SVM), and Random Forest (RF), were tested in the study. In the field of machine learning, k-fold cross-validation, especially the 10-fold cross-validation, is most commonly used to verify the performance of a model. The parameter k randomly splits the data into k subsets, and one of the subsets is chosen for testing with the remaining k \(-\) 1 subsets for training. The procedure is repeated until each subset is treated as a testing set. The total number of original data samples used for training the model was 440. Due to the k-fold cross-validation method with k = 10, the training data accounted for 396, and the verification data accounted for 44. The confusion matrixes, including the true positive count (TP), false positive count (FP), false negative count (FN), and true negative count (TN), are mainly used to evaluate a classification model's performance. For describing the model's performance, TP, TN, FP, and FN are frequently combined into several indices, such as accuracy, recall, and precision, and they can be formulated by Equations (2)-(5). \[\text{Accuracy}=\frac{\text{TP}+\text{TN}}{\text{TP}+\text{TN}+\text{FP}+ \text{FN}} \tag{2}\]  
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{3}\]  
\[\text{True Negative Rate}=\frac{\text{TN}}{\text{TN}+\text{FP}} \tag{4}\]  
\[\text{Precision}=\frac{\text{TP}}{\text{TP}+\text{FP}} \tag{5}\]  
The model performance obtained by the use of the four algorithms is shown in Table 3. As a result, all models could ideally predict the visible stray light of three types of VR HMDs with high accuracy and acceptable true negative rate, whereas the models needed to improve for the recall. The four approaches' accuracy was about 90%, and the logistic regression algorithm performed the best. Nevertheless, it is essential that more experiments be conducted and more VR HMDs tested to build a comprehensive model. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multicolumn{2}{c}{**Model**} & **Accuracy** & **Recall** & **True Negative Rate** & **Precision** \\ \hline \multirow{4}{*}{KNN} & Average \(\pm\) SD & 88.6\% \(\pm\) 2.7\% & 84.7\% \(\pm\) 5.1\% & 90.8\% \(\pm\) 2.6\% & 80.3\% \(\pm\) 4.8\% \\ \cline{2-6}  & Min \(\pm\) SD & 89.1\% \(\pm\) 2.0\% & 73.4\% \(\pm\) 7.0\% & 92.2\% \(\pm\) 2.4\% & 65.3\% \(\pm\) 7.8\% \\ \cline{2-6}  & Max \(\pm\) SD & 91.6\% \(\pm\) 1.4\% & 88.8\% \(\pm\) 3.9\% & 93.6\% \(\pm\) 2.3\% & 91.4\% \(\pm\) 2.8\% \\ \hline \multirow{4}{*}{\ \begin{tabular}{c} Logistic Regression \\ \end{tabular}  } & Average \(\pm\) SD & 91.1\% \(\pm\) 1.6\% & 85.1\% \(\pm\) 3.4\% & 94.2\% \(\pm\) 2.0\% & 88.1\% \(\pm\) 3.5\% \\ \cline{2-6}  & Min \(\pm\) SD & 91.4\% \(\pm\) 1.9\% & 79.3\% \(\pm\) 7.4\% & 93.8\% \(\pm\) 2.0\% & 71.6\% \(\pm\) 7.8\% \\ \cline{2-6}  & Max \(\pm\) SD & 93.2\% \(\pm\) 1.7\% & 92.4\% \(\pm\) 4.0\% & 93.8\% \(\pm\) 3.3\% & 91.8\% \(\pm\) 3.6\% \\ \hline \multirow{4}{*}{SVM} & Average \(\pm\) SD & 90.5\% \(\pm\) 1.3\% & 88.7\% \(\pm\) 3.2\% & 91.4\% \(\pm\) 1.7\% & 80.5\% \(\pm\) 3.5\% \\ \cline{2-6}  & Min \(\pm\) SD & 91.8\% \(\pm\) 2.2\% & 80.3\% \(\pm\) 7.4\% & 93.8\% \(\pm\) 2.2\% & 71.6\% \(\pm\) 8.3\% \\ \cline{2-6}  & Max \(\pm\) SD & 93.0\% \(\pm\) 1.6\% & 92.1\% \(\pm\) 4.2\% & 93.4\% \(\pm\) 2.7\% & 91.0\% \(\pm\) 2.8\% \\ \hline \multirow{4}{*}{ \begin{tabular}{c} Random Forest \\ \end{tabular}  } & Average \(\pm\) SD & 90.0\% \(\pm\) 2.7\% & 85.5\% \(\pm\) 4.7\% & 92.6\% \(\pm\) 2.6\% & 84.6\% \(\pm\) 4.5\% \\ \cline{2-6}  & Min \(\pm\) SD & 91.2\% \(\pm\) 1.7\% & 80.2\% \(\pm\) 7.5\% & 93.5\% \(\pm\) 2.2\% & 76.1\% \(\pm\) 8.1\% \\ \cline{2-