# Spatiotemporal Assessment and Correction of Gridded Precipitation Products in North Western Morocco
## 2 Materials and Methods
### Methodology
#### 2.3.1 Classification Metrics  
In classification, the objective is to predict the outcome from a finite set of categorical values [43]. Simply put, a classification metric quantifies how well a machine learning model assigns observations to specific classes [44]. Classification metrics can be categorized into three main groups: binary, multiclass, and multilabel. The confusion matrix, also known as an error matrix, is a specific tabular representation that provides a visual depiction of a model's performance [45; 46]. As the name implies, it is an NxN matrix (Table 2) [47], where N represents the number of predicted classes. The confusion matrix consists of two dimensions, \"Actual\" and \"Predicted\", with \"Classes\" represented along each dimension. Various performance measures are computed based on the values in the confusion matrix. When evaluating the performance of a precipitation estimation model from a classification perspective, there are four possible outcomes:  
1. True Positive (TP): this indicates the number of days when both the ground observation and the satellite predict the occurrence of rainfall. 2. True Negative (TN): this parameter signifies the absence of rainfall, as neither the satellite nor the observation recorded any precipitation. 3. False Positive (Type I Error) (FP): this denotes instances where the satellite incorrectly identifies a rainfall event that is not present in the observed data. 4. False Negative (Type II Error) (FN): this represents the number of days when the satellite fails to detect a rainfall event that is recorded by the rain gauge. Classification accuracy (ACC) is a widely used metric for evaluating a model's performance. It measures the ratio of correct predictions to the total number of predictions made on a dataset. ACC provides an overall success rate, where a perfect score of 1 indicates zero false positives (FP) and false negatives (FN) [48]. Conversely, classification error (Err) represents the ratio of incorrect predictions to the total number of predictions, reflecting the proportion of incorrect estimates made by the model [49]. Each prediction made by a product to determine the true class of the target contributes to an error. This results in false positives (FP) and false negatives (FN), indicating misclassifications compared to the true class. The precision, also known as the positive predictive value (PPV), focuses on minimizing false positives or false alarms. The precision is defined as the fraction of all positive predictions that are true positives [48; 50]. Recall, also known as the true positive rate (TPR) or sensitivity, represents the number of true positives divided by the sum of true positives and false negatives. In other words, recall captures the fraction \begin{table}
\begin{tabular}{c c c c} \hline \hline  & & \multicolumn{2}{c}{**Actual Value**} \\ \cline{3-4}  & & **Positive** & **Negative** \\ \hline \multirow{2}{*}{Predicted Value} & Positive & TP (True Positive) & FP (False Positive) \\ \cline{2-4}  & Negative & FN (False Negative) & TN (True Negative) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Confusion matrix for binary classification. of all actual positives that are correctly predicted as positives [50; 51]. High recall with low precision indicates that most positive examples are correctly identified (low number of false negatives), but there are also many false positives. Conversely, low recall with high precision suggests that many positive examples are missed (high false negatives), but the ones predicted as positive are indeed positive (low number of false positives). There exists a trade-off between precision and recall, making it challenging to optimize both simultaneously. Improving precision, which focuses on reducing false positives, often leads to a deterioration in recall, which concerns false negatives, and vice versa. This raises the question of which metric should be prioritized: precision or recall?