2
$\begingroup$

I'm using the root mean squared error (RMSE) as a metric for tuning the parameters of my model in a regression problem through cross-validation. However, I'm not so much interested that all predictions are good, I want that about 20% or 40% percent of my predictions to be "spot-on" and don't care if the other 80% or 60% are garbage.

What metric would be best for this?

$\endgroup$
3
  • 2
    $\begingroup$ Look at the entire distribution of residuals. This should be directly available in any decent software after regression. No omnibus statistic can be anything more than a particular summary. Unfortunately, you should care if 60% or 80% of your predictions are garbage; that may mean that you are fitting an inappropriate model and that may mean that the model is not to be trusted any way. $\endgroup$
    – Nick Cox
    Commented Oct 30, 2015 at 10:12
  • 2
    $\begingroup$ why would you care only about 20% of your predictions? $\endgroup$
    – rep_ho
    Commented Feb 5, 2020 at 11:26
  • $\begingroup$ I don't think it's fair to criticize OP for asking this question. We don't know the specific problem they're working on. We can assume they've done their due diligence and offer solutions based on the question they asked, not the question we wished they asked. $\endgroup$
    – Eli
    Commented Jun 29, 2023 at 15:54

2 Answers 2

1
$\begingroup$

You could try the Huber loss function. It penalizes close predictions more than predictions that are very wrong.

Using the usual notation for Huber Less, define $a_i$ as your residual, $Y_i - \hat{Y}_{i}$. Huber loss is defined as

$$ L_\delta(a) = \begin{cases} \frac{1}{2} a^2, & \text{for $|a| < \delta$} \\ \delta * (|a| - \frac{1}{2}\delta), & \text{for $|a| \geq \delta$} \end{cases}$$

You define a threshold of "closeness", $\delta$. If your prediction is within this threshold, your loss is quadratic. If your prediction is outside of this threshold, your loss is linear. This let's the model prioritize fitting points that your model is close to getting correct and de-prioritize outliers. If you want to de-emphasize outliers even further, you could increase the polynomial degree in the case when $|a| < \delta$ and/or decrease the polynomial degree when $|a| \geq \delta$.

In R, you can calculate Huber Loss with the yardstick package. I'm not aware of any out-of-the-box implementations of Huber loss as a standalone metric in Python. Sklearn let's you fit linear regression with Huber Loss. but Huber Loss isn't one of sklearn's scoring metric.

$\endgroup$
-1
$\begingroup$

Answering my own question here, it seems that the root mean squared log error (RMSLE) is a suitable metric, see this CV post

$\endgroup$
1
  • 5
    $\begingroup$ This can't be a general answer without a rationale. $\endgroup$
    – Nick Cox
    Commented Oct 30, 2015 at 10:14

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.