Visual walkthrough — Log and power transformations
We build in pictures. Every new tool — including the two calculus ideas "limit" and "derivative" — is introduced with its own plain-words box before we use it. Let us start with what "skew" even looks like.
Step 1 — What "right-skewed" means, as a shape
WHAT. We have a column of positive numbers — say incomes or prices. Most values are small; a few are enormous. When we draw a histogram (bars whose height = how many values fall in that slice), the bump sits on the left and a long thin tail stretches to the right.
WHY. Every later step exists to fix this exact shape. A model like Linear Regression wants a symmetric, bell-ish spread. So first we must see the enemy.
PICTURE. Look at the burnt-orange bars below. The word "right-skewed" just means: the tail points right (toward big numbers). The plum arrow marks the tail we want to shorten.

Step 2 — The power function is a "shape dial"
WHAT. Take each value and raise it to a power (the Greek letter lambda — just a name for "the exponent we get to choose"). Different bend the number line differently.
WHY. We need some knob that squashes big numbers more than small ones. Powers less than do exactly that: turns into but into — the giant shrank 10×, the small one only 2×. That differential squashing is what pulls the tail in.
PICTURE. Each curve below is for a different . Turn the dial down (toward ) and the curve flattens — the far-right tail gets crushed toward the others. Turn it up past and the tail stretches instead.

Step 3 — Why raw has an ugly seam at
WHAT. Watch what does as slides down to . For any positive , . So at the instant , every value collapses to the single number .
WHY. A transformation that turns all your data into "" is useless — it erased every difference. So plain cannot be used at ; there is a hole in our dial right where we most want a logarithm to appear.
PICTURE. The curves in Step 2 all funnel toward the same height at . Below we zoom on that collapse — three different starting values () all crash to .

Step 4 — The repair: subtract , divide by
WHAT. Replace with
WHY each piece:
- The re-centres. Since near hovers around , subtracting moves that whole cluster down to hover around instead. Now the values are differences from , which are tiny — not all collapsed onto .
- The re-scales. Those tiny differences shrink as ; dividing by the equally-tiny rescues them from vanishing. Small ÷ small = something finite and useful.
Together they take the "everything crashes to " seam and stretch it back open into a well-behaved curve. Crucially, this rescaling doesn't reorder your data — bigger still maps to bigger (the rank order is preserved, which is why tree splits are unaffected).
PICTURE. Left panel: raw (the collapsing family from Step 3). Right panel: after ", then " — the curves no longer pile onto ; they fan out around and stay distinct even as the dial approaches .

Step 5 — Two calculus tools we need first: "limit" and "derivative"
WHAT. Before we can find what the repaired dial does at , we need two ideas. Both are just precise names for things you already picture.
WHY. In Step 6 we hit the meaningless form . The trick that resolves it (L'Hôpital's rule) compares the two curves' slopes — so we genuinely need the derivative idea in hand first. This step is that hand.
PICTURE. Left: a ball creeping toward along , homing in on a height (the limit) even though the exact point is a hollow dot. Right: the same curve with a little tangent ramp drawn at one point — its steepness is the derivative.

Step 6 — Why
WHAT. We need the slope of as changes (with held fixed). The answer is . Here is why, from the ground up — no memorising.
WHY / derivation. The clean route is to rewrite using , because we know how raised to something behaves.
- What we did: replaced by (true by the very definition of : ), then used "a power of a power multiplies the exponents."
- Why: now the exponent is just times the constant , and has a slope we can read off.
The single growth fact we lean on: the curve rises at a rate times its own current height. (That is what makes special — its slope equals itself when .) Here the constant is , so
PICTURE. For a fixed , we plot against and draw the tangent ramp at a point; its measured steepness matches (teal dot vs. plum ramp). The factor is literally why the ramp is steeper for bigger — and thus why a logarithm is about to surface.

Step 7 — At the repaired dial becomes the logarithm
WHAT. We ask: what value does approach as ? At the fraction reads — meaningless on its own, so we take the limit (Step 5) and resolve the with L'Hôpital's rule.
Check the fine print for our case, , , at :
- both as ✓ (it is genuinely );
- is differentiable everywhere (Step 6 gave ) and is differentiable with ✓;
- everywhere ✓;
- the slope-ratio limit exists (we compute it next) ✓.
All hypotheses hold, so we may swap top and bottom for their derivatives:
So the hole in the dial is plugged by itself — not bolted on arbitrarily, but demanded by continuity.
PICTURE. The teal dots trace at for a fixed ; the plum curve is . Watch the dots march onto the plum curve as .

Step 8 — Reading the special settings on the dial
WHAT. Now that the dial is smooth, name the useful clicks.
WHY. In practice you rarely eyeball ; scipy.stats.boxcox searches for the that makes the histogram most symmetric. But knowing the landmarks tells you what family of squash you're getting.
| Formula becomes | Effect on the tail | |
|---|---|---|
| none (just a shift) | ||
| gentle squash | ||
| strong squash | ||
| extreme squash / flip |
PICTURE. The same skewed data from Step 1, pushed through four settings. As drops, the plum tail retracts; the bump slides right toward symmetry.

Step 9 — The degenerate cases you must not miss
WHAT & WHY. Two edges break Box-Cox; you must recognise them before they crash your pipeline.
Case A — or . Box-Cox needs (you can't raise to a negative power, and ). If your column has zeros, shift it: with chosen from domain sense. If it has genuine negatives (temperature anomalies, profit/loss), Box-Cox is impossible — switch to Yeo-Johnson.
Yeo-Johnson is not simply "the same on each side." For negatives it uses a different exponent and sign-flips so the two halves meet smoothly at . The full four-piece rule:
Notice the negative branch: it flips to (making a positive number), raises it to the conjugate exponent (not ), divides by , then negates the whole thing. Those specific exponent and sign choices are exactly what make the two branches share the same value and the same slope at — that is what "continuous and differentiable across zero" requires. A naive "just mirror the trick" would leave a kink at .
Case B — known only from data. is a learned parameter. Learn it on the training set only, then apply that same frozen to test data — exactly like fitting a scaler in Feature Scaling. Learning on all data leaks the test distribution.
PICTURE. A number line split at : green region (, Box-Cox legal), red region (, Box-Cox forbidden → Yeo-Johnson), with the mirror-image arrow showing how Yeo-Johnson reflects the transform across .

The one-picture summary
WHAT. Everything on one canvas: the dial running from down through , through (=), to ; a skewed input on the left; a symmetric output on the right; the "" repair labelled where it lives.

Recall Feynman retelling — say it like a story
We had lopsided data: a crowd of small numbers and a few monsters stretching a long right tail. We wanted a knob that squashes monsters harder than the crowd. Raising every number to a power is that knob — pick and big numbers shrink far more than small ones. But the raw knob jams at : everything raised to the becomes , wiping out our data. So we patched the knob: subtract (slide the jam-point down to ) and divide by (blow the now-tiny differences back up to useful size). To find what the patched knob settles on as creeps to (a limit — the value we're heading toward without landing on it), we hit ; L'Hôpital's rule says a fraction heads toward the ratio of its two slopes (derivatives), provided both pieces are smooth and the bottom's slope isn't zero — all true here. Since grows at rate times itself, its slope is , and the ratio spits out exactly . So the natural logarithm isn't a separate tool bolted on; it's the click of one smooth dial. The "" we subtract is a harmless constant — it never changes the shape/skew, only the mean. Finally: the dial only works for positive numbers; zeros/negatives need Yeo-Johnson, whose negative branch uses the conjugate exponent and a sign-flip so the two halves join without a kink. And always learn on training data alone so no test information leaks in.
Recall Quick self-test
Why does raw fail at ? ::: Because for every , collapsing all data onto a single value and destroying all information. What do the "" and "" each accomplish? ::: The re-centres the cluster (which hovers near ) down to near ; dividing by the tiny rescales the resulting tiny differences back to finite size. In plain words, what is a limit? ::: The single value a function's outputs home in on as the input creeps toward a target, without needing to plug the target in. In plain words, what is a derivative? ::: The slope of the curve at a point — how fast the output changes when the input is nudged a hair. Why is ? ::: Because , and grows at rate times its height, with here. What are L'Hôpital's hypotheses? ::: Both top and bottom (form ), both differentiable near the point, the bottom's derivative is nonzero there, and the slope-ratio limit exists. What value does approach as ? ::: . Box-Cox on with ? ::: . Why doesn't the "" affect skewness? ::: Skewness is invariant to adding a constant or multiplying by one; the only shifts the mean/intercept, not the shape. On the negative branch of Yeo-Johnson, what exponent is used and why? ::: The conjugate exponent (with a sign-flip), chosen so the value and slope match the positive branch at — no kink. When must you abandon Box-Cox for Yeo-Johnson? ::: When the data contains zeros or negative values, since Box-Cox requires .
See also: Parent: Log and power transformations · Polynomial Features (the opposite move — adding bend) · Linear Regression Assumptions (why we un-bend at all).