Curious Minds

Clear answers to science and history questions

Root Mean Square Log Error (RMSLE) Explained

· 6 min read · Science

Root mean square log error (RMSLE) measures the difference between predicted and actual values after taking their natural logarithms, then squares and averages those differences. You enter two lists of numbers (actuals and predictions) and get back a single score where lower is better, with 0 meaning a perfect match. This page explains the formula, why the log transform matters, and how to interpret the result in real modeling contexts.

in y | Actual values (comma-separated) | - | 100, 150, 200, 250, 300 | 0 | 1000000
in p | Predicted values (comma-separated) | - | 110, 140, 210, 240, 310 | 0 | 1000000
out rmsle | RMSLE | - | sqrt(mean((ln(p+1)-ln(y+1))^2)) | 4

Formula

The RMSLE is defined as:

RMSLE = sqrt( (1/n) * Σ (ln(p_i + 1) - ln(y_i + 1))^2 )

  • y_i – actual value of the i-th observation (must be ≥ 0)
  • p_i – predicted value for that observation (must be ≥ 0)
  • n – number of observations
  • ln – natural logarithm (base e)

The “+1” inside the log ensures the function is defined even when a value is zero, since ln(0) is undefined. The logarithm compresses large values and stretches small ones, so the error is measured in relative terms rather than absolute units.

Worked Example

Using the default inputs: actuals = [100, 150, 200, 250, 300], predictions = [110, 140, 210, 240, 310].

  1. Add 1 to each value and take natural logs:
    Actual logs: ln(101)=4.6151, ln(151)=5.0173, ln(201)=5.3033, ln(251)=5.5255, ln(301)=5.7071
    Predicted logs: ln(111)=4.7095, ln(141)=4.9488, ln(211)=5.3519, ln(241)=5.4848, ln(311)=5.7398
  2. Subtract actual log from predicted log (or vice versa – squaring removes sign):
    Differences: 0.0944, -0.0685, 0.0486, -0.0407, 0.0327
  3. Square each difference: 0.00891, 0.00469, 0.00236, 0.00166, 0.00107
  4. Average the squares: (0.00891+0.00469+0.00236+0.00166+0.00107)/5 = 0.003738
  5. Take square root: sqrt(0.003738) = 0.0611

The calculator returns RMSLE ≈ 0.0611, matching the default output.

Why Use Logs?

RMSLE is popular in regression tasks where the target variable spans several orders of magnitude – for example, house prices, store sales, or population counts. A plain RMSE would be dominated by errors on large values; a single mistake of 1,000 on a value of 10,000 would swamp a 10-unit error on a value of 100. Taking logs turns those into comparable relative errors: ln(11000)-ln(10000) ≈ 0.0953, while ln(110)-ln(100) ≈ 0.0953 as well. That way, a 10% error counts the same whether the true value is 100 or 10,000.

This property makes RMSLE especially useful when you care about percentage accuracy rather than absolute accuracy. It also penalizes underestimates more heavily than overestimates – because the log curve is steeper near zero, a prediction that is too low by a factor of 2 yields a larger squared difference than a prediction that is too high by the same factor.

How to Interpret the Result

RMSLE is not in the original units of your data; it’s in log-units. A rough interpretation: if your RMSLE is 0.1, then typical predictions are off by about 10% in relative terms (since e^0.1 ≈ 1.105). Values below 0.05 indicate very good relative accuracy; above 0.3 suggests the model is struggling. However, there is no universal “good” threshold – it depends on the problem and the noise level in the data.

You can compare RMSLE values across different models on the same dataset; the lower the better. But do not compare RMSLE across datasets with different scales or distributions, because the log transform changes the meaning.

Common Mistakes and Limitations

  • Forgetting the +1 – If any value is zero, ln(0) is undefined. Always add 1 (or a small constant) before taking logs.
  • Using negative values – RMSLE is only defined for non-negative values. If your data can be negative, use RMSE or another metric.
  • Mixing up log base – The formula uses natural log (ln). If you use log10, the result will be scaled by a factor of ln(10)≈2.3026, which changes the numeric value.
  • Ignoring the asymmetry – RMSLE treats underestimates as worse than overestimates. If that bias is not desirable, consider symmetric metrics like MAPE or SMAPE.
  • Not checking for outliers – While logs dampen the effect of large values, extreme outliers can still inflate RMSLE. Robust alternatives exist.

RMSLE vs. RMSE vs. MAE

RMSE (root mean square error) is the same formula without the log transform. It measures absolute error in the original units, so it’s easier to interpret but heavily affected by scale. MAE (mean absolute error) is the average absolute difference; it’s less sensitive to outliers than RMSE. RMSLE sits between: it’s relative, but still squares the differences, so it penalizes large relative errors more than MAE would.

Choose RMSLE when your target is positive and spans multiple orders of magnitude, and when you care about percentage error. Choose RMSE when the scale is uniform and absolute error matters. Choose MAE when you want a robust metric that isn’t swayed by outliers.

When to Use RMSLE in Practice

RMSLE is commonly used in Kaggle competitions and business forecasting for metrics like sales, demand, or revenue. For example, if you’re predicting daily sales for thousands of stores, some stores sell 10 items a day and others sell 10,000. A model that is off by 100 items on the big store is fine, but off by 100 on the small store is terrible – RMSLE captures that distinction. It is also used in price prediction (real estate, insurance) and any count data that is strictly positive.

If your data contains zeros (e.g., no sales on a given day), the +1 trick handles it, but be aware that the relative error for zero values is undefined – a prediction of 1 vs. actual 0 gives a log difference of ln(2)-ln(1)=0.693, which is a fixed penalty. That might be acceptable or not depending on your problem.

Frequently Asked Questions

What is a good RMSLE score?

There is no universal benchmark. A score below 0.1 typically indicates that predictions are within about 10% of actual values on average. Scores above 0.5 suggest the model is not capturing the pattern well. Always compare against a baseline model (e.g., predicting the mean) to see if your model adds value.

Can RMSLE be negative?

No. Since it’s a square root of an average of squares, RMSLE is always non-negative. A score of 0 means perfect predictions (all predicted values equal actual values after the +1 transform).

What if my predicted values are negative?

RMSLE requires non-negative inputs. If your model outputs negative values, you need to clip them to zero or use a different metric. Alternatively, you could use a transformation like log1p on the predictions after clipping.

Why add 1 before taking the log?

Adding 1 ensures that zero values are handled gracefully, because ln(0) is undefined. It also makes the metric symmetric in the sense that both actual and predicted values get the same shift. The choice of 1 is arbitrary; some use a small epsilon, but 1 is standard.

Does RMSLE penalize underestimates more than overestimates?

Yes. Because the log function is concave, the difference ln(p+1)-ln(y+1) is larger in magnitude when p < y than when p > y for the same relative error. This makes RMSLE biased against underestimation, which is often desirable in inventory or sales forecasting where running out of stock is worse than having surplus.

Can I use RMSLE for classification?

No, RMSLE is for regression tasks with continuous or count targets. For classification, use metrics like accuracy, precision, recall, or log loss.

In this article
  1. Formula
  2. Worked Example
  3. Why Use Logs?
  4. How to Interpret the Result
  5. Common Mistakes and Limitations
  6. RMSLE vs. RMSE vs. MAE
  7. When to Use RMSLE in Practice
  8. Frequently Asked Questions