# Automated Fillet Weld Inspection Based on Deep Learning from 2D Images
## 2 Materials and Methods
### Methodology
#### 2.4.7 Performance Metrics (PM)  
In order to demonstrate the rigor of this research and to be able to measure the performance of the YOLO algorithm used by making a fair and reliable comparison, the following metrics have been defined:  
* Recall (R): It is also called sensitivity or TPR (true positive rate), representing the ability of the classifier to detect all cases that are positive, Equation (1). \[Recall(R)=\frac{TP}{TP+FN}\] (1) TP (True Positive) represents the number of times a positive sample is classified as positive, i.e., correctly. On the other hand, FN (False Negative) tells us the number of times a negative sample is classified incorrectly.
* Precision (P): Controls how capable the classifier is to avoid incorrectly classifying positive samples. Its definition can be seen in Equation (2). \[Precision(P)=\frac{TP}{TP+FP}\] (2) In this case, FP (false positive) tells us how many times negative samples are classified as positive.
* Intersection over union (IoU): is a critical metric in object detection as it provides a quantitative measure of the degree of overlap between a ground truth (gt) bounding box and a predicted (pd) bounding box generated by the object detector. This metric is highly relevant for assessing the accuracy of object detection models and is used to define key terms such as true positive (TP), false positive (FP), and false negative (FN). It needs to be defined because it will be used to determine the mAP metric. Its definition can be seen in Equation (3).  
\[InterSection\ over\ union(IoU)=\frac{area(gt\cap pd)}{area(gt\cup pd)} \tag{3}\]
* Mean Average Precision (mAP): in object detection is able to evaluate model performance by considering Precision and Recall across multiple object classes. Specifically, mAP50 focuses on an IoU threshold of 0.5, which measures how well a model identifies objects with reasonable overlap. Higher mAP50 scores indicate better overall performance. For a more comprehensive evaluation, mAP50:95 extends the evaluation to a range of IoU thresholds from 0.5 to 0.95. This metric is appropriate for tasks that require precise localization and fine-grained object detection. mAP50 and mAP50:95 are able to help evaluate model performance across multiple conditions and classes, thereby expressing information about object detection accuracy by considering the trade-off between Precision and Recall.  
\[Average\ Precision(AP)=\int_{x=0}^{x=1}P(R)\cdot dR \tag{4}\]  
Models with higher mAP50 and mAP50-95 scores are more reliable and suitable for demanding applications. These are appropriate metrics to ensure success in projects such as autonomous driving and safety monitoring.  
Equation (4) shows the calculation of Average Precision, which is necessary to calculate the mean Average Precision (mAP), as demonstrated in Equation (5).  
\[Mean\ Average\ Precision(mAP)=\frac{1}{N}\sum_{n\in N}AP(n) \tag{5}\]
* Box loss: this loss helps the model to learn the correct position and size of the bounding boxes around the detected objects. It focuses on minimizing the error between the predicted boxes and the ground truth.
* Class loss: the accuracy of object classification is of paramount importance. The system is designed to ensure that each detected object is correctly classified into one of the predefined categories.
* Object loss: object loss is responsible for choosing between objects that are very similar or difficult to differentiate, by better understanding their characteristics and spatial information.