1
$\begingroup$

As precipitation prediction models can only predict positive values, they won't be able to undershoot small values by much. When it comes to overshooting, there is no boundary. High precipitation values can essentially be overshot and undershot equally, except a model predicts ridiculously large amounts. Furthermore, if previous weather has been dry, simple models, such as the moving average can easily predict zero values. This issue I'd like to address. I've come up with a custom variant of the RMSE (cRMSE). Would this address this issue?

np.sqrt(np.mean((y_true - y_pred)**2 + w * np.exp(-np.abs(y_true))))

The cRMSE is a custom implementation of the Root Mean Squared Error (RMSE) error metric. This could be a potentially useful approach for precipitation forecasting, as it incorporates an additional weighting factor w $\in\{ℝ|0<w<1\}$ applied to values close to zero for y_true.

The cRMSE metric could be useful in cases where you want to give less weight to values close to zero, for example, in situations where predicting zero values accurately is considered less important than predicting non-zero values. The weighting factor w allows adjusting the impact of the additional term in the error metric, and you can experiment with different values of w to find the best balance between accuracy for non-zero values and tolerance for zero values.

$\endgroup$
1
  • $\begingroup$ If you have a theoretical reason to adopt such a metric, that ought to be enough. But otherwise it helps to employ some principles to guide you. At stats.stackexchange.com/a/201864/919 I discuss some of them and provide a comprehensive account of the options. What I don't discuss there is the relationship between a probability model and the metric, but that's a big topic. In many cases, especially in physical applications like this one, it works best to start with a reasonable model and develop the metric accordingly. $\endgroup$
    – whuber
    Commented Apr 11, 2023 at 15:55

1 Answer 1

0
$\begingroup$

It sounds like you want to implement weighted RMSE, where the weights are set according to the y_true values. To do this in a way that will be useful for discriminating between models that make different predictions, you should use multiplication instead of addition on the weight term:

np.sqrt(np.mean((y_true - y_pred)^2 * w * (y_true))

The use of addition as you suggested would made the added error term dependent solely on the y_true values but not on the predictions - every model would see its error measure increase by a fixed amount, so it's the equivalent of simply adding an arbitrary constant. By using multiplication instead, the actual error terms get weighted by the y_true values, meaning that models which make different predictions will see their error measure change by different amounts.

$\endgroup$
6
  • $\begingroup$ but wouldn't this, for a big enough y_true, essentially set the error to 0 regardless of (y_true - y_pred)? $\endgroup$
    – schefflaa
    Commented Apr 11, 2023 at 20:01
  • $\begingroup$ @schefflaa Whoops, I misread the exponential there - I updated the formula, we can scale the error values by y_true itself. When y_true=0, the sample does not contribute any error no matter how bad the prediciton is. $\endgroup$ Commented Apr 11, 2023 at 20:26
  • $\begingroup$ wouldn't this, for y_true=0, even for horrendous predictions, result in an error of 0 for the sample? The multiplicative part is still strange to me $\endgroup$
    – schefflaa
    Commented Apr 13, 2023 at 11:56
  • $\begingroup$ @schefflaa Yes, I thought that was the goal? The question says you want something for "situations where predicting zero values accurately is considered less important than predicting non-zero values". Here, predicting values whose true value is close to zero is less important than predicting values far from zero, and the predictions for true values that are exactly zero don't matter at all. You could add some small epsilon value to the y_true in this formula if you want zero-valued samples to contribute small amounts of error rather than none at all. $\endgroup$ Commented Apr 13, 2023 at 13:32
  • $\begingroup$ Yeah you're right in this. I should have clarified my question more. As were calculating the mean of the error of our samples, for example, [50, 12, 0] the error of 0 is a very good prediction and counts the same way to our mean as the other two values. Your formula would then, as i was trying to say, result in 0 for a horrendous prediction if y_true=0, which then counts the same towards the other samples. The formula I posted in the orignial question would overcome this through addition. $\endgroup$
    – schefflaa
    Commented Apr 13, 2023 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.