AI Glossary / Natural language and speech / Foundation
Logistic function
Definition
The logistic function maps a real-valued input to an S-shaped output. In its standard form, σ(z) = 1/(1 + exp(−z)), the output lies strictly between zero and one for finite inputs. This form is widely used to convert a binary model's score into an estimated probability.
What it means
A model may combine evidence into a score that is negative, positive or very large. Such a score is not automatically a valid probability. The standard logistic function, also called the logistic sigmoid or expit, places it on a bounded scale.
An input of zero maps to 0.5. Positive inputs map above 0.5 and negative inputs below it. The curve becomes flatter toward either end, so adding the same amount to the input does not always produce the same change in output.
The function itself does not learn from data or establish that an estimate is accurate. A trained model supplies the input, and calibration must be assessed against observations. More general logistic curves can include location, scale and upper-limit parameters; this entry focuses on the standard form used in binary classification.
How it works
In binary logistic regression, a weighted sum of features and an intercept produces z. Applying σ(z) gives the model's estimated probability of the designated positive class. The complementary class receives probability 1 − σ(z).
The inverse relationship connects the function to log odds. If p = σ(z), then z = ln[p/(1 − p)]. Thus an additive change in z corresponds to a multiplicative change in the odds, not a fixed percentage-point change in probability.
The derivative is σ(z)(1 − σ(z)). It is largest at z = 0, where it equals 0.25, and becomes small near the tails. This explains the curve's central sensitivity and flatter extremes. It also matters when the function participates in gradient-based learning.
A decision threshold is separate from this transformation. Choosing to act when p exceeds 0.5, 0.8 or another threshold is a policy choice that should reflect the task and error costs.
Three practical examples
- A binary text classifier maps its weighted score to a probability estimate for whether a message belongs to a specified category.
- A neural-network gate uses a sigmoid-shaped value between zero and one to control the strength of a signal.
- An analytics explanation contrasts equal score changes at different starting points to show why probability changes are nonlinear.
Think of it this way
Think of a flexible gauge whose middle responds readily while its ends compress increasingly large inputs into a bounded display. It can show a usable range without clipping every large value at the same fixed point.
The analogy concerns the transformation only. A gauge is useful only when connected to a meaningful measurement, and a logistic output is useful only when the underlying model and interpretation are justified. The bounded display does not guarantee trustworthy evidence.
Worked example
Transforming scores and applying a threshold
An invented binary classifier produces scores z = −2, 0 and 2 for three messages. The standard logistic function gives approximately 0.1192, 0.5000 and 0.8808. These are model estimates, not verified labels for the messages.
Suppose the illustrative action rule requires an estimated probability of at least 0.80. Only the third message meets it. The score corresponding to exactly 0.80 is ln(0.80/0.20) = ln(4) ≈ 1.3863, so the rule can equivalently be applied at that score threshold under this model.
Increasing the score from −2 to 0 raises the probability by about 0.3808. Increasing it from 2 to 4 raises the probability from about 0.8808 to 0.9820, only about 0.1012. Equal score increments therefore need not produce equal probability increments. The example illustrates the curve and threshold conversion, not a recommended operating threshold.
Illustrative case study
A fictional internal-document team uses a classifier to route messages for review. Its dashboard presents logistic outputs as percentages. During a trial, staff interpret an 80% estimate as a guarantee that four out of every five individual decisions will be correct.
The team clarifies the predicted event and evaluates groups of predictions against reviewed labels. It also separates the displayed estimate from the routing threshold and documents how different thresholds affect missed cases and unnecessary reviews.
The lesson is that the logistic function provides a mathematical probability parameterization. Evidence about calibration and decision performance comes from evaluation, not from the fact that the output lies between zero and one. No trial results are asserted for this fictional team.
Common misconceptions and mistakes
- A logistic output is automatically calibrated. The transformation alone does not ensure agreement with observed frequencies.
- The function itself is the entire model. A model must supply its input and be trained or otherwise specified.
- Equal score increments give equal probability increments. The relationship is nonlinear.
- The logistic function imposes a 0.5 action threshold. Threshold selection is a separate decision.
Business use
The logistic function appears in interpretable classifiers, neural-network components and probability displays. Understanding it helps business readers ask what a percentage represents and where it came from.
When reviewing a model, distinguish the score calculation, probability transformation and operating threshold. Test calibration and outcomes on data representative of the intended use. If a probability display is rounded to 0% or 100%, remember that finite mathematical inputs to the standard function never reach the endpoints exactly; numerical rounding can hide that distinction. Avoid treating a saturated display as proof of certainty.
People also ask
Is the logistic function the same as every sigmoid?
No. Sigmoid describes a broader S-shaped family; the logistic sigmoid is one specific function.
What input produces 0.5?
Zero in the standard form.
Does it handle mutually exclusive multiclass outputs by itself?
A single standard logistic output addresses one binary probability. Multiclass models commonly use a normalized transformation such as softmax.
Check your understanding
A score rises by two units. Must its logistic probability rise by the same amount as every other two-unit score increase?
Answer: No. The change depends on the starting score because the curve is steepest near zero and flatter toward its extremes.
Related terms
- Sigmoid
- Logistic regression
- Logit
- Odds
- Probability calibration
- Activation function
- Softmax
- Gradient
- decision threshold
Learn next
Evaluate the standard function at several negative and positive inputs, then convert a chosen probability threshold back to log odds. Keep the mathematical transformation separate from evidence that a model's estimates are calibrated.
More in Natural language and speech
- Log odds ratio - A log odds ratio is the logarithm of the ratio between two odds. It compares the relative odds of the same event in two groups or conditions.
- Log probabilities - Log probabilities are logarithms of probabilities.
- Logic form - A logic form, in the NLP convention covered here, is a structured representation of a sentence using predicates and shared arguments.
- Logit lens - The logit lens is an interpretability technique that maps intermediate language-model representations into vocabulary scores using the model's output readout.
- Lookahead in regex - Lookahead in a regular expression checks whether a pattern does or does not match at the current position without consuming the characters inspected.
- Loudness - Loudness is the perceived strength of a sound, from quiet to loud.
Sources
Jurafsky and Martin, Speech and Language Processing, Chapter 4: https://web.stanford.edu/~jurafsky/slp3/4.pdf. Standard sigmoid, binary classification and logit relationship. SciPy, expit documentation: https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.expit.html. Function definition and inverse relation. Numerical examples are original calculations.
Previous: Logico-linguistic modeling Next: Logistic loss