# Weed Detection in Wheat Crops Using Image Analysis and Artificial Intelligence (AI)
## 3 Materials and Methods
### Performance Metrics  
We used a range of measures, including mean average precision (MAP) and mean intersection over union (mIOU), to assess the model's performance on our dataset and statistically compare the many YOLO iterations. In order to guarantee a fair comparison and to take into account any differences in the data, we also chose varied numbers of photos across the versions.  
The performance of the models utilized in this work was assessed using accuracy, recollection, accuracy and inaccuracy ratios, [PERSON]'s correlation coefficient, F1-scores and an implication period (Table 4). A positive predictive value is another term used for precision. It is a ratio that measures the neural network's performance by dividing the amount of accurate TP by the summation of true positive and FP (Equation (1)). The best and worst precisions are 1.0 and 0.0, respectively.  
\[\text{Accuracy}=\text{TP}/(\text{TP}+\text{FP}) \tag{1}\]  
Recall is computed by multiplying TP by the sum of TP and FN. Recall is also known as sensitivity and the true confident rate (Equation (2)). Its value is between 0 and 1. The effectiveness of the neural network in weed detection was evaluated using recall.  
\[\text{Recall}=\text{TP}/(\text{TP}+\text{FN}) \tag{2}\]  
Precision refers to the proportion of correctly predicted positive instances (true positives) out of all instances that were predicted as positive, whether they were true or false  
\begin{table}
\begin{tabular}{c c c c} \hline \hline  & \multicolumn{3}{c}{**Actual Values**} \\ \hline  & \multicolumn{2}{c}{Wheat} & \multicolumn{1}{c}{Weed} \\ Predicted & Wheat & TP & FP \\ Values & Weed & FN & TN \\ \hline TP: true positive, FP: false positive, FN: false negative, and TN: true negative. & & \\ \end{tabular}
\end{table}
Table 4: The misperception medium developed utilizing justification, and the taxing results of images for classification model using the four potential situations.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Batch Size & 64 \\ Image Size & 416 \(\times\) 416 \\ Epochs & 100 \\ Solver type & Leaky RELU \\ Base Learning rate & 0.00261 \\ Learning rate policy & Exponential decay \\ Momentum & 0.95 \\ \hline \hline \end{tabular}
\end{table}
Table 3: The lists of hyper-parameters for the training of models YOLOv3-Tiny and YOLOv4-Tiny.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Batch Size & 32 \\ Image Size & 640 \(\times\) 640 \\ Epochs & 100 \\ Solver type & Adam \\ Base Learning rate & 0.001 \\ Learning rate policy & Exponential decay \\ Momentum & 0.95 \\ \hline \hline \end{tabular}
\end{table}
Table 2: The lists of hyper-parameters for the training of models YOLOv5s, YOLOv5l and YOLOv5m.  
positives. In other words, it measures the accuracy of positive predictions. Precision can be calculated using the following formula (Equation (3)):  
\[\text{Precision}=\text{TP}/(\text{TP}+\text{FP}) \tag{3}\]  
The F1-score, on the other hand, is the harmonic mean of precision and recall (sensitivity). The F1-score is a balanced measure of precision and recall, and is used when the distribution of classes is uneven. F1-score can be calculated using the following formula (Equation (4)):  
\[\text{F1-Score}=2\ ^{*}(\text{Precision}\ ^{*}\ \text{Recall})/(\text{Precision }+\text{Recall}) \tag{4}\]  
Equation (5) is used to determine [PERSON]'s correlation coefficient, which accounts for all four variables in the conflict matrix.  
\[\text{MCC}=\text{TP}\times\text{TN}-\text{FP}\times\text{FN}\]  
\[(\text{TP}+\text{FP})\ (\text{TP}+\text{FN})\ (\text{TN}+\text{FP})\ (\text{TN}+\text{FN}) \tag{5}\]  
[PERSON]'s correlation coefficient (MCC) is a metric used to evaluate the performance of binary detection and classification problems. It is effective in evaluating imbalanced datasets. Its value ranges from 1 to \(-1\), representing perfect detection or classification as \(1\), totally incorrect detection as \(-1\), and a somewhat random output as 0.