Log-Odds vs Probability: How Logistic Regression Really Works

log odds probability logistic regression works
Image by Editor
 

Logistic regression is used to predict a binary, categorical outcome — such as Yes vs. No, True vs. False, and so on — based on one or more predictor variables, modeling the input–prediction relationship as an S-shaped curve given by the logistic (sigmoid) function.

There are two types of outputs commonly obtained in logistic regression: log-odds and probabilities. While they are two ways to describe the same prediction outcome, they have different aims, and their distinction should be understood to avoid confusion.

In its base form, logistic regression does not directly return output probabilities; rather, it computes the target outcome’s log-odds — also known as logits and denoted by t — based on a linear combination of p input features x1 to xp, similar to multiple linear regression.

The diagram below shows:

  • How to calculate log-odds
  • How to turn log-odds into a target or “positive” outcome probability p
  • The other way around: how to obtain the log-odds from positive (p) and negative (1 − p) outcome probabilities


logistic regression log odds probability
Logistic regression in a nutshell: log-odds and probability | Image by Author
 

Let’s discuss the key differences between the two outputs:

Notice that log-odds t can be positive or negative and, unlike probabilities, are not bounded. This makes them straightforward for modeling the logistic regression mechanism but not as interpretable. This is why log-odds are usually mapped to probabilities in the range [0, 1] using the sigmoid function, interpreted as “How likely is outcome A to happen?”

Another, more nuanced difference is how each output varies as the input features change. Log-odds respond linearly and evenly to changes in inputs, whereas probabilities do not. Due to the S-shape of the sigmoid, small changes in inputs can sometimes have a large impact on the resulting probability (especially when t is near 0), and at the extremes the probability changes more slowly.

A Code Example

This example illustrates the relationship between a set of given log-odds and their associated probabilities by applying the sigmoid function. This snippet uses NumPy:

 
import numpy as np

# Example logits (assumed to be raw model outputs)
log_odds = np.array([-2.0, -0.5, 0.0, 1.0, 2.0])

# Converting log-odds to probabilities by applying the logistic function
probabilities = 1 / (1 + np.exp(-log_odds))

for lo, p in zip(log_odds, probabilities):
    print(f"log-odds: {lo:>4}, probability: {p:.3f}")

Key Takeaway

In sum, log-odds are the natural logistic regression outputs, while probabilities are derived and easier to interpret. Both are correct: they simply need to be interpreted at different levels. The former is closer to how the model “thinks,” while the latter is closer to how humans reason about uncertainty.

Leave a Reply

Your email address will not be published. Required fields are marked *