Log-Odds
Odds are the ratio of a probability to its complement, \(p/(1-p)\). A probability of 0.8 gives odds of \(0.8/0.2 = 4\): success is four times as likely as failure. Log-odds are the natural logarithm of that ratio,
\(\operatorname{logit}(p) = \ln\!\left(\dfrac{p}{1-p}\right)\)
which is where the name logit comes from. The transformation sends \((0, 1)\) onto the whole real line: 0.5 maps to 0, probabilities above 0.5 map to positive numbers, and probabilities approaching 0 or 1 run off to \(-\infty\) and \(+\infty\).
Why the log
Removing the bounds is the usual explanation, and it is only half of it. A linear predictor \(\beta_0 + \beta_1 x_1 + \cdots\) can take any real value, so a model of a probability needs a link that connects that unbounded predictor to the interval \((0, 1)\). Odds alone, bounded below by zero, do not make that connection; log-odds do, and their inverse, the sigmoid, always returns a valid probability. But the more important property is what the logarithm does to combination.
Evidence multiplies odds. Two independent pieces of evidence, each doubling the odds, leave them four times higher. Taking logs turns that into addition, and addition is what a linear model does. So
\(\ln\!\left(\dfrac{p}{1-p}\right) = \beta_0 + \beta_1 x_1 + \cdots + \beta_n x_n\)
is not a convenience chosen to make the algebra work. It is the claim that each predictor contributes a fixed multiplicative effect on the odds, independently of the others โ a strong assumption, and one worth checking rather than inheriting.
The same additivity is why Bayesian updates are often written on this scale. Bayes’ rule multiplies prior odds by a likelihood ratio, so in log-odds the posterior is the prior plus the log likelihood ratio, and several pieces of evidence accumulate by addition.
Reading a coefficient
A coefficient \(\beta\) is the change in log-odds for a one-unit change in its predictor. Exponentiating gives \(e^{\beta}\), the odds ratio โ the factor by which the odds are multiplied. This is generally offered as the interpretable form, and it is, provided it is read as a statement about odds.
import numpy as np
def logit(p):
return np.log(p / (1 - p))
def sigmoid(z):
return 1 / (1 + np.exp(-z))
beta = 0.7
odds_ratio = np.exp(beta)
starting = np.array([0.02, 0.10, 0.50, 0.90, 0.98])
after = sigmoid(logit(starting) + beta)
print(f"one-unit coefficient {beta}, odds ratio {odds_ratio:.4f}")
for p0, p1 in zip(starting, after):
print(f" p {p0:.2f} -> {p1:.4f} odds {p0/(1-p0):7.4f} -> {p1/(1-p1):7.4f} change in p {p1-p0:+.4f}")
# one-unit coefficient 0.7, odds ratio 2.0138
# p 0.02 -> 0.0395 odds 0.0204 -> 0.0411 change in p +0.0195
# p 0.10 -> 0.1828 odds 0.1111 -> 0.2238 change in p +0.0828
# p 0.50 -> 0.6682 odds 1.0000 -> 2.0138 change in p +0.1682
# p 0.90 -> 0.9477 odds 9.0000 -> 18.1238 change in p +0.0477
# p 0.98 -> 0.9900 odds 49.0000 -> 98.6739 change in p +0.0100
The odds ratio is 2.0138 in every row, exactly as advertised. The change in probability is not: the same coefficient moves a probability by +0.0100 at one end of the range and +0.1682 in the middle, a factor of seventeen. The probability scale compresses near 0 and 1, and the logit scale is the inverse of that compression.
Two practical consequences follow. A coefficient cannot be translated into an effect on probability without saying where the starting point is โ “this feature raises the chance by 8 percentage points” is incomplete unless a baseline accompanies it. And an odds ratio of 2 is a large effect when probabilities are small and a modest one when they are near 0.5, which is the reverse of the intuition most readers bring.
The same care applies to the phrase that usually accompanies odds. A customer with odds of 9 is nine times as likely to buy as not to buy. They are not nine times as likely to buy as a customer with a probability of 0.5, whose odds are 1 โ that comparison is also a factor of nine in odds, but the probabilities are 0.9 against 0.5.
Where you meet it
- Logistic regression estimates its coefficients on this scale, and the quantity it computes per case before the sigmoid is the modeled log-odds. In scikit-learn that value comes from
decision_function, documented only as a confidence score “proportional to the signed distance of that sample to the hyperplane” โ see model score. - Neural networks call the pre-sigmoid outputs logits. In the binary case that is exact โ the value is the log-odds of the probability the model reports โ but it says nothing about whether those odds are the ones that occur, which is calibration. In a multi-class softmax only the differences between logits are log-odds ratios, since adding a constant to all of them changes nothing.
- Epidemiology and clinical research report odds ratios directly, which is why the distinction between an odds ratio and a risk ratio matters there.
Working on this scale rather than converting back and forth โ averaging models, undoing a sampling ratio, rescaling confidence โ is covered under logit space.
References
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
