Sigmoid (Logistic) Function: Mapping to Probability

The sigmoid function takes any real number and squishes it onto a scale between 0 and 1. This makes it perfect for converting the output of a linear model into a probability.


Logit Function: Mapping to Log-Odds

The logit function does the exact opposite of the sigmoid function. It takes a probability and stretches it out onto an infinite scale. This is a two-step process that goes through Odds.

1. From Probability to Odds

First, we convert the probability into odds, which is the ratio of the probability of an event happening to the probability of it not happening.

2. From Odds to Log-Odds (The Logit)

Next, the logit function simply takes the natural logarithm of the odds. This final step transforms the odds scale [0, +∞] to the log-odds scale [-∞, +∞].


The Mismatch Problem

You can't directly map an unbounded output to a bounded one. Trying to say "let the output of the linear model be the probability" would fail, as the model could easily predict a probability of 1.5 or -0.2, which is nonsensical.


The Solution: Change the Scale

Instead of changing the model, we change the scale of the target variable. The logit function (ln(p1p)ln(\frac{p}{1-p})) provides the perfect solution.

By converting the probability (0 to 1) into log-odds (negative to positive infinity), you create a new target variable that matches the unbounded nature of the linear model.

This allows a linear model to do what it does best: predict a value on an infinite scale. That value (the log-odds) can then be effortlessly converted back into a valid probability using the sigmoid function.

In short, the conversion creates a mathematical "bridge" that connects the unbounded world of linear models with the bounded world of probability. 🌉


© 2025 James Yap

Personal Website and Knowledge Base