# Traffic Light Detection and Recognition Method Based on YOLOv5s and AlexNet
## 4 Analysis of Experimental Results  
To validate the performance of the model, evaluation metrics such as precision (P), recall (R), average precision (AP), and mean average precision (mAP) [30] are generally selected to evaluate the trained network model. Accuracy is the ratio of the correct positive class found to all positive classes found. On the other hand, recall rate describes how many real positive examples in the test set are selected by the dichotomy classifier, that is, how many real positive examples are recalled by the dichotomy classifier. The accuracy and recall rates are calculated as follows:  
\[Precision=\frac{TP}{TP+FP}\times 100\% \tag{6}\]  
\[Recall=\frac{TP}{TP+FN}\times 100\% \tag{7}\]  
where _TP_ indicates the number of targets correctly detected, _FP_ represents the number of targets that were misdetected, and _FN_ indicates the number of undetected samples. In general, the better the classifier is, the higher the average precision value is. The average precision value is the area under the precision-recall curve. The precision-recall curve in this paper is shown in Figure 11, where the epoch is the number of times all training datasets were trained. Analysis of Figure 11 shows that the area under the precision-recall curve is as high as 0.993, which is a very desirable figure and proves that the average precision value of the training results of the model. Figure 10: Data enhancement results. The average precision mean is the average of \(AP\)s of multiple categories. The mean average precision and average precision are calculated as follows:  
\[AP=\int_{0}^{1}P(R)dR \tag{8}\]  
\[mAP=\frac{\sum PA}{NC} \tag{9}\]  
The \(mAP\) is one of the most important metrics in the target detection algorithm, and its value must be in the interval \([0,1]\). The larger, the better. The \(mAP\) curves for thresholds greater than 0.5 and for different IoU thresholds (from 0.5 to 0.95 in steps of 0.05) are shown in Figure 12.  
Analysis of Figure 12 shows that the values of [EMAIL_ADDRESS] and [EMAIL_ADDRESS]:0.95 gradually increase as the epoch gradually increases. The final [EMAIL_ADDRESS] can reach 99.39%, while the [EMAIL_ADDRESS]:0.95 can also reach 77.47%. Figure 11: Precision–recall curve. Figure 12: mAP curve. The loss value is another important measure of network performance and is used to gauge how close the network is to a perfect prediction when making predictions on the entire training image set. In YOLOv5s, GIoU is used as the loss function of the Bounding box, with smaller loss values representing more accurate detection of the box. The mean GIoU loss function curve is shown in Figure 13.  
Analysis of Figure 13 shows that as the number of training sessions increases, the loss function gradually becomes smaller, and at about 25 training sessions the rate of decline decreases and begins to converge gradually, finally levelling off and reaching the ideal state. In this paper, we also compare the performance exhibited by YOLOv5s, YOLOv4 [31], and Faster R-CNN [32] in traffic light detection by applied transfer learning. The test results are shown in Table 2.  
By comparing the mAPs of the three methods, it is obvious that YOLOv5s have higher recognition accuracy compared with YOLOv4 and Faster R-CNN. To demonstrate the validity of the experimental results more accurately, we will use these three methods to detect the same image, as shown in \[Recall=\frac{TP}{TP+FN}\times 100\% \tag{7}\]0  
The detection results of YOLOv5s (a), YOLOv4 (b) and Faster R-CNN (c) are shown in \[Recall=\frac{TP}{TP+FN}\times 100\% \tag{7}\]1 From the comparison, it can be seen that YOLOv4 has the worst result and does not detect the traffic light. yolov5s can accurately locate the traffic light with high confidence. faster R-CNN can detect the traffic light, but the detected position deviates more and the result is not satisfactory.