AI Glossary / Statistics and probability / Intermediate
Mean squared logarithmic error
Definition
Mean squared logarithmic error, or MSLE, is the average squared difference between the natural logarithms of one plus each actual value and one plus its prediction. It is commonly used with nonnegative targets when differences on a compressed, approximately relative scale are relevant. MSLE evaluates squared errors after the transformation log(1 + value), rather than squaring errors in the original units.
What it means
The logarithm compresses large values. As a result, a given absolute miss generally matters less when both the actual and prediction are large than when they are small. The added one permits an actual value of zero without taking the logarithm of zero.
MSLE is not a percentage error and is not simply the logarithm of MSE. It gives a particular mathematical meaning to error that may suit some tasks, but using it does not establish that the model is appropriate for a business objective.
How it works
Align predictions with observed outcomes and establish the target domain. The conventional application uses nonnegative actuals and predictions. Although the expression log(1 + x) is mathematically defined for x greater than minus one, that fact alone does not justify applying the metric to a task with negative outcomes. Check software requirements separately.
Transform each value using the natural logarithm of one plus that value. Subtract the transformed prediction from the transformed actual, square the difference, and average across observations. Thus MSLE = average of [ln(1 + actual) minus ln(1 + predicted)] squared.
Equivalently, each term is the squared logarithm of the ratio (1 + actual)/(1 + predicted). This explains the metric's relationship to proportional discrepancies on the shifted scale. For large positive values, the added one becomes comparatively small, but near zero it strongly affects interpretation.
The square root gives root mean squared logarithmic error, or RMSLE. Neither quantity is an error in the original target units. Report the exact transformation and any weighting or output aggregation.
Use a reserved evaluation set or appropriate cross-validation. A correct metric calculation cannot repair information leakage, mismatched forecast horizons, or missing outcomes. Compare models on the same observations and preprocessing rules.
Three practical examples
- Demand forecasting: a team evaluates nonnegative item demand spanning very different volumes, provided the transformed loss reflects its priorities.
- Audience modeling: analysts compare predictions of nonnegative view counts while also checking original-scale errors on high-traffic content.
- Personal projects: someone predicts nonnegative activity counts and uses the transformed score to avoid having only the largest counts dominate an initial comparison.
Think of it this way
Think of measuring distances after drawing a chart on a compressed axis. Equal gaps on that chart do not represent equal differences in the original quantity. MSLE squares and averages gaps on a log-one-plus axis, so its usefulness depends on whether that axis represents the mistakes that matter.
Worked example
Actual counts are 0, 3, and 15; predictions are 1, 7, and 7. After adding one, the actual values are 1, 4, and 16, while predictions become 2, 8, and 8.
The ratios of shifted actuals to shifted predictions are one-half, one-half, and two. Their natural logarithms are -ln(2), -ln(2), and ln(2). Every squared transformed error is therefore [ln(2)] squared, approximately 0.480453. MSLE is also 0.480453, and RMSLE is ln(2), approximately 0.693147.
In original units, squared errors are 1, 16, and 64. Their mean is 27. These two scores answer different questions; MSLE is not ln(27).
For an asymmetry example, hold the actual at nine. Predicting four underpredicts by five and gives [ln(10/5)] squared, approximately 0.480453. Predicting fourteen overpredicts by the same five and gives [ln(10/15)] squared, approximately 0.164402. The equal absolute misses receive different penalties. However, reciprocal ratios on the shifted scale receive equal penalties because their logarithms differ only in sign.
Illustrative case study
Fictional case: Maple Media predicts weekly views for articles with widely varying audiences. Its team finds that MSLE emphasizes a different set of mistakes from ordinary MSE. Before choosing a model, it checks both scores and reviews large missed audiences in original units.
The team also documents how zero-view articles and negative model outputs are handled. It does not silently clip predictions only during reporting. This fictional scenario illustrates metric selection and disclosure; it does not assert that MSLE produces better forecasts or higher business returns.
Common misconceptions and mistakes
Do not call MSLE scale invariant. Changing units changes the influence of the added one, especially for small observations. Do not present RMSLE as an average percentage error or an average count error.
The statement that underprediction is penalized more heavily needs a comparison rule: it holds for equal absolute deviations around a fixed nonnegative actual when both predictions remain admissible. It does not mean that every underprediction is worse than every overprediction.
Do not assume transformed-loss training predicts the arithmetic mean of the original outcome. Under suitable finite-moment conditions, minimizing expected squared transformed error targets the mean of log(1 + outcome). Transforming that mean back generally differs from averaging original outcomes.
Business use
Use MSLE when compressed-scale errors fit the decision and the target domain supports the transformation. Report original-scale errors as well when staffing, inventory, or capacity decisions depend on absolute quantities.
For a simple illustration of the prediction target, equally likely outcomes zero and eight have an arithmetic mean of four. Their transformed mean is [ln(1) + ln(9)]/2 = ln(3), which transforms back to two. This distinction can materially affect planning, so a lower transformed loss should not automatically settle the operational choice.
People also ask
Can MSLE handle zeros?
Yes, because ln(1 + 0) equals zero.
Is lower better?
Lower means smaller average squared transformed error on comparable data.
Is it the same as MAPE?
No; MAPE divides absolute errors by actual values, whereas MSLE compares logarithms of shifted values.
Check your understanding
when actual and prediction are equal, what is their contribution?
Answer: zero.
is RMSLE the square root of MSLE?
Answer: yes.
do equal original-scale overprediction and underprediction necessarily receive equal MSLE penalties?
Answer: no, because the transformation changes their distances.
Related terms
- Mean Squared Error
- Conditional expectation
- Root mean squared logarithmic error
- Log transformation
- Regression loss
- Relative error
- Count prediction
Learn next
Next, compare MSLE with MSE and percentage errors on the same small dataset. Then examine transformed-target regression and why back-transformed predictions need an interpretation tied to their loss function.
More in Statistics and probability
- Mean opinion score - A mean opinion score, or MOS, is an average of ratings assigned on a predefined opinion scale in a quality-evaluation study.
- Mean Percentage Error - Mean Percentage Error, or MPE, is the arithmetic average of signed forecast errors expressed as percentages of the corresponding actual values.
- Mean pooling - Mean pooling is an operation that combines a collection of equally sized vectors by averaging their corresponding coordinates.
- Mean time to failure - Mean time to failure, or MTTF, is the expected operating time until a defined failure for an item or population under specified conditions.
- Measurement error - Measurement error is the difference between a measured value and an appropriate reference value.
- Measurement model - A measurement model describes how observations, corrections, and other relevant quantities relate to the quantity being measured.
Sources
Scikit-learn, mean_squared_log_error documentation: https://scikit-learn.org/stable/modules/generated/sklearn.metrics.mean_squared_log_error.html Scikit-learn, model evaluation, mean squared logarithmic error: https://scikit-learn.org/stable/modules/model_evaluation.html
Previous: Mean Squared Error Next: Mean squared projected Bellman error