# Using Machine Learning to Predict Pedestrian Compliance at Crosswalks in Jordan
## 4 Results and Discussion  
The analysis of pedestrian behavior at various intersections revealed a predominance of male pedestrians, making up 61.7% of the total, with females accounting for 38.3%. Adults were the majority, especially near Yarmouk University and shopping centers, while children and elders were fewer, with distinct spatial variations in their distribution. Most pedestrians crossed streets directly without pauses, and a significant number carried personal items, particularly in areas near schools and business districts. A majority of 72.5% crossed paths without any interaction with vehicles, whereas 19.7% crossed with moderate risk and 7.8% with high risk of vehicle interaction. The preference for walking over running was evident, with 95.8% walking and only 4.2% running across the street. The classification models were built using a 10-fold cross-validation method. This method divides the data set into ten subsets, and a process with ten iterations is followed. At each iteration, a new subset is used for testing the model, while the rest of the subsets are used for training. The prediction models are evaluated using the confusion matrix. This matrix reveals, for each class, the number of correctly and incorrectly classified instances. A 2 \(\times\) 2 confusion matrix for two classes is presented in Table 3. The TP, TN, FP, and FN can be described as follows:  
* True Positive (TP): positive instances classified as positive. * True Negative (TN): negative instances classified as negative. * False Positive (FP): negative instances classified as positive. * False Negative (FN): positive instances classified as negative. The accuracy rate or precision is one of the most widely adopted measures to evaluate the classifier's overall performance. The higher the accuracy is, the better the model performs. The accuracy represents the ratio of correctly classified instances to all instances and is calculated as follows:  
\[Accuracy=\frac{TP+TN}{TP+FP+FN+TN} \tag{7}\]  
True Positive Rate (TPR) and False Positive Rate (FPR) are also important measures. TPR or Recall represents the ratio of instances that were correctly classified as positive instances, while FPR is the ratio of instances that were incorrectly classified as positive to all instances that are not positive:  
\[FPR\left(Recall\right)=\frac{TP}{TP+FN} \tag{8}\]  
\[FPR=\frac{FP}{TN+FP} \tag{9}\]  
Note that the overall accuracy of a classifier can also be calculated by taking the weighted average of all recall values. Precision is another measure representing the ratio of instances that were correctly classified as positive to all instances that were classified as positive. The model performance increases as the TPR and precision values increase and FPR value decreases. \[Precision=\frac{TP}{TP+FP} \tag{10}\]  
Finally, the ROC curve plots the TPR against the FPR at several threshold settings, which represents the trade-offs between true positive (benefits) and false positive (costs). The ROC values range from 0.0 to 1.0, where 1.0 is the optimal case. Table 4 presents the performance of ANN, ID3, RF, and SVM. Each model's total accuracy was computed, as were the weighted precision and weighted FPR for each method. Also, Figure 2 provides a graphical representation of the performance achieved by all classification models. \begin{table}
\begin{tabular}{c c c} \hline \hline  & \multicolumn{2}{c}{**Predicated Class**} \\ \hline True Class & Positive & Negative \\ \hline Positive & TP & FN \\ \hline Negative & FP & TN \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Confusion matrix. As noted, the RF technique achieved the best accuracy (81.2%) and precision (80.9%) in determining pedestrian compliance compared to the other methods. The FPR value was also low (25.2%), indicating that the model is effective and accurate. The ANN and ID3 techniques also performed well, with ID3 performing the worst in terms of FPR value. The performance of the SVM technique was the least accurate of the other techniques used in this study.