Data ScienceMathematics and statistical foundations

Log transformations: interpret predictions on the original scale

PK
Pankit Kumar
Sr. Data Scientist at Parexel (a Goldman Sachs–backed company) · 20 September 2026 · 3 min read
Technically reviewed by Ishaan Sharma
In this article (5 sections)

Exponentiating a prediction on the log scale does not generally recover the conditional mean on the original scale. The nonlinear transformation makes the target statistic matter.

Consider an original positive-outcome teaching model: log(Y)=mu+epsilon, where mu=log(100) and epsilon is normal with mean zero and standard deviation 0.6. Under these assumptions, the original-scale median is 100, while the mean is approximately 119.72.

This example explains retransformation; it does not claim that all revenue, duration or demand data follow a lognormal distribution.

Name the statistic the model estimates

Under squared-error fitting on log(Y), an ideal model estimates the conditional mean of log(Y). In our stated symmetric normal residual model, exponentiating mu also gives the conditional median of Y. The conditional mean of Y is instead exp(mu+sigma**2/2).

The SciPy lognormal reference documents the relationship between a normal variable and its exponential. Its scale=exp(mu) parameter is not the arithmetic mean when sigma is positive.

Without the residual assumptions, exponentiating a conditional log mean is not automatically a median either. Distinguish a property of this model from a universal rule about every log transformation.

Reproduce the reference and simulation

The lab includes 200,000 synthetic draws generated with integer seed 20261003. No external dataset is required.

python
import numpy as np
from model_geometry import log_case

r = log_case()
assert np.isclose(r['median'],100)
assert np.isclose(r['mean'],119.72173631218104)
assert np.isclose(r['mean'],r['scipy_mean'])
assert r['mean'] > r['median']
assert abs(r['simulated_mean']-r['mean']) < 1
assert abs(r['simulated_median']-r['median']) < 1
print(r)

The recorded sample mean is about 119.4833 and sample median about 99.9650. They are close to, but not exactly equal to, their population targets. The one-unit tolerance is an explicit simulation check, not a confidence interval.

Select a retransformation method with evidence

If a normal, constant-variance log residual model is appropriate, the variance correction above has a clear interpretation. If residual spread depends on features, a single global correction can misrepresent particular groups.

More generally, E(Y|X)=exp(mu(X))*E(exp(epsilon)|X) for the declared decomposition. Estimating the second factor from residuals requires care about fit optimism, representative data and whether it changes with X. A residual-based correction is not justified merely because it makes aggregate totals look closer on the training sample.

Evaluate the final predictions on the scale and metric relevant to the decision. Good log-scale error does not guarantee good original-scale total forecasts, especially when large outcomes have substantial operational importance.

Handle zeros and interpretation explicitly

The natural logarithm requires positive inputs. Adding a constant or using log1p changes the transformation and its inverse. It does not make zero and negative outcomes disappear conceptually. Record why the chosen transformation matches the data-generating and decision context.

For a log-linear model, exponentiated coefficient differences describe multiplicative changes under the model. They are not automatically causal effects. A change in predicted median should not be labelled a change in predicted mean unless the assumptions supporting that interpretation are stated.

Exercise: set sigma to zero, then to one, while keeping mu=log(100). Calculate the median and mean in both cases. Explain why using 100 as an expected total contribution per observation increasingly understates the model's mean as residual spread grows.

NeuraPath's Data Science course connects transformations with evaluation and business interpretation. A complete prediction report names the transformed target, inverse operation and original-scale statistic being delivered.

Continue learning

This article is part of the Mathematics and statistical foundations sequence. Use the neighbouring tasks when you need the prerequisite or the next application.

PK
Pankit Kumar
Lead Instructor, NeuraPath Academy

Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.

This article is part of our Data Science programme — 6 months. From data foundations to machine learning, deep learning and deployment.

Explore Data Science
Counselling is free · no obligation

Not sure which programme fits?

Tell us your background and we will map it to the right entry point — including saying so when a cheaper programme is the better fit. A counsellor replies within one working day.