3.1. Principle
To solve the high noise and class imbalance problem in CML-based rainfall intensity prediction, a cost-sensitive rainfall intensity prediction model (CSRFP) adds an attention-embedding layer (AEL) with spatiotemporal scene information and uses a rainfall cross-entropy loss (RF-CEL) for disciplining. CSRFP is divided into two parts: training and inference, and the structure is shown in
Figure 1.
The model can allow the input time series to contain numerical data such as signal strength and character data such as spatiotemporal scene information. In the AEL, spatiotemporal scene information is embedded into dimensionally appropriate vectors, which are assigned different weights by the model and then merged with signal features. Normalization follows the AEL to unify the scales of all features, enhancing model stability. During training, the normalized training set data enters the recursive and linear layers, and the RF-CEL performs loss calculation and iteration. RF-CEL assigns appropriate weights to the training results based on the distribution probability of different rainfall intensities, making the model sensitive to costs. In inference, the normalized validation set or test set data passes through the recursive and linear layers, and the probability corresponding to each rainfall intensity is directly output by the SoftMax layer. This process ensures that the model can adequately account for varying rainfall intensity distributions, improving adaptability and stability across different scenarios.
3.3. Rainfall Cross-Entropy Loss
RF-CEL evolved from cross-entropy loss (CEL, denoted as
LCE) and Weibull distribution of rainfall over a specific time period. CEL is a commonly used loss function in classification tasks. However, for datasets with class imbalances, relying solely on CEL often does not yield satisfactory results. In the context of multi-class tasks, the definition of CEL is as follows:
where
N stands for the number of samples;
C represents the number of classes;
is a binary indicator, which has a value of one when sample
i is divided into class
j, and zero otherwise; and
is the probability as predicted by the model that sample
i belongs to class
j. When one class greatly outnumbers the others in the sample set, CEL mainly reflects the classification accuracy of that dominant class. In cases with complex feature relationships or weaker data-label correlations, relying solely on CEL can cause the model to neglect minority classes.
To counteract this issue, a weighting factor α is introduced in the balanced cross-entropy loss (BCEL). This adaptation is designed to improve upon the limitations encountered when using CEL in scenarios with intricate feature relationships or subdued data-label connections. The definition of BCEL is as follows:
In the BCEL, the set of weights allows for the adjustment of the loss contribution from different classes by tuning the size of α. However, α does not dynamically adjust the computation of losses. This means that for different rainfall datasets, it might be necessary to design distinct weights, making its application somewhat limited in scope.
Specifically, in the context of rainfall intensity prediction, a novel adjustment factor z can be introduced to construct a cost-sensitive loss function. This factor can be derived by integrating the distribution of rainfall with the rain attenuation effect, thereby tailoring the loss computation to more accurately reflect the nuances of rainfall data. This approach allows for a more effective and cost-sensitive handling of class imbalances in rainfall intensity prediction models.
The Weibull distribution is one of the most common distributions for rainfall [
34]. Let RF denote the random variable representing rainfall rate. The probability density function of rainfall following the Weibull distribution is as follows:
In this equation,
r represents the rainfall amount, and
a,
b,
μ are the distribution parameters, determined by the when geographic conditions. By integrating
, the cumulative probability distribution of RF can be obtained as follows:
According to reference [
35,
36], the Z–R relationship in rainfall intensity prediction can be approximated as follows:
In this expression,
Z is known as the radar reflectivity or unit rain attenuation,
r is the rainfall amount, and
q,
k are empirical coefficients. By defining the inverse function of Equation (4) as
and substituting it into Equation (5), the following relationship can be derived:
Assuming that the rainfall factor
Z has the same form as radar reflectivity
Z, which gives the rainfall factor
Z a certain degree of practical significance. Therefore, the expression for RF-CEL can be formulated as follows:
From Equation (5), it is evident that as the numerical value of radar reflectivity Z decreases, the numerical value of rainfall amount r also decreases, showing a positive correlation between the two. From Equation (4), it is observed that as the rainfall amount r decreases, the probability p increases, indicating a negative correlation between them. As the forms of z and Z are identical, therefore, z and p are negatively correlated. As the probability nears one, the corresponding coefficient approaches zero. Conversely, as decreases, tends towards infinity. In scenarios such as the anticipation of no rainfall, a scenario often aligned with the predominant class, the probability tends to be notably elevated. Consequently, this circumstance leads to diminished penalties for inaccuracies in predictions. Conversely, for instances associated with the minority class, the inverse holds true. Introducing the coefficient z facilitates cost-sensitive learning within the realm of rainfall intensity forecasting, thereby modulating the model’s sensitivity to different classes in accordance with their individual probabilities.
3.4. Evaluation Metrics
In classification tasks, accuracy, defined as the proportion of correctly predicted samples to the total number of samples, is commonly used as a metric for evaluating model performance. However, in scenarios with class imbalance, accuracy often fails to effectively reflect the model’s true performance. As the imbalance becomes more pronounced, the value of accuracy as a metric further diminishes. For imbalanced multi-class problems, metrics like recall, precision, the area under the curve (AUC) and
F-measure are more reliable metrics of performance. The confusion matrix for binary classification problems is illustrated as shown in
Table 1.
In the macro measurements,
Recall,
Precision, and
F1 are defined as follows:
The receiver operating characteristic (ROC) curve is a widely used tool for observing model performance. The curve’s vertical axis represents the true positive rate (TPR), and the horizontal axis represents the false positive rate (FPR). Here, TPR is equivalent to precision, while FPR is defined as . ROC curves are suitable for assessing the overall performance of classifiers. However, in imbalanced classification tasks, if the combined sample size of all other classes is greater than the size of one class, an increase in FP has a relatively small impact on FPR. This can lead to an overestimation of the model’s performance in ROC analysis. The precision–recall (P-R) curve addresses this issue by plotting recall on the horizontal axis and precision on the vertical axis, thereby eliminating the effects of many negative samples. The closer the P-R curve approaches the upper right corner, or the ROC curve approaches the upper left corner, the better the model’s classification performance. However, different curves may intersect, and the AUC provides a more intuitive means of comparing the performance of different classifiers. The AUC value ranges from zero to one. In multi-class tasks, for a particular class, an AUC greater than 0.5 indicates that the classifier can distinguish that class; otherwise, it lacks such ability.
Recall, Precision, , , and F1 metrices introduced above can comprehensively reflect the prediction performance of the model from multiple dimensions. In the rainfall prediction based on CMLs, the comprehensive consideration of these metrics can greatly improve the reliability of the results compared with the accuracy of single use.