AI Glossary / Probabilistic machine learning / Advanced
Bayesian logistic regression
Definition
Bayesian logistic regression models a binary outcome using a logistic probability function and prior distributions over regression coefficients. It combines those priors with observed outcomes to obtain a posterior distribution, allowing predictions and coefficient summaries to account for uncertainty about the fitted relationship.
What it means
A conventional logistic regression model relates predictors to the probability of an outcome such as whether an item passes inspection. A Bayesian version retains a distribution over plausible coefficients rather than relying only on a single fitted coefficient vector.
This does not make every uncertainty disappear or every prediction trustworthy. Posterior conclusions depend on the likelihood, priors, available data and inference method. A model may express narrow uncertainty within its assumptions while still missing an important feature of the real process.
How it works
For observation i, set η_i = α + x_iᵀβ and p_i = 1/(1+exp(−η_i)). Model the binary outcome as Bernoulli(p_i), usually assuming conditional independence across observations unless additional structure is included. Specify priors for α and β, then update them using the likelihood.
Posterior computation often uses sampling or an approximation. For a new input, calculate its probability under each posterior coefficient draw and average these probabilities. This integrates parameter uncertainty. Choosing an action or classification threshold is a separate decision and can depend on error costs. A coefficient describes a change in log odds, not a constant percentage-point change in probability.
Three practical examples
- A manufacturer could estimate whether a component will pass a defined inspection using measured properties. It would need to validate probabilities on later production batches and check whether the modeled relationships remain relevant.
- A subscription service could investigate associations between recent usage and renewal. Predictive associations would not establish that changing a usage measure causes renewal.
- A research team could compare prior assumptions when fitting a small binary-outcome dataset. Examining their effects on predictions would reveal whether the available evidence supports a stable conclusion.
Think of it this way
Imagine several plausible curves relating a measured input to the chance of an event. Data make some curves more credible than others. Prediction combines the probabilities supplied by those curves according to their posterior support. Averaging the curves' parameters first is a different operation because the logistic transformation is nonlinear.
Worked example
For an original calculation, suppose three equally weighted illustrative posterior draws give intercept and slope pairs (α,β) of (−2,1), (−1,0.5) and (0,1). These values are stipulated for teaching; they are not the output of a fitted dataset, and three draws would not establish reliable inference in practice.
Predict for a new input x=2. The three linear predictors α+βx are 0,0 and 2. Applying the logistic function gives probabilities 0.50,0.50 and approximately 0.880797. The draw-averaged predictive probability is (0.50+0.50+0.880797)/3, approximately 0.626932.
Now try a shortcut. The average intercept is −1 and the average slope is 5/6. Using these averages gives a linear predictor of −1+(5/6)×2 = 2/3. Its logistic probability is approximately 0.660756, different from 0.626932. Transforming the averaged coefficients has not reproduced the averaged predictive probability.
The difference is about 3.38 percentage points in this toy calculation. It does not always have this size or direction. Also, 0.626932 is a probability for a binary outcome; the actual next observation would still be either zero or one. This example illustrates posterior prediction, not model fitting, calibration or evidence of real-world accuracy.
Illustrative case study
Fictional quality-control business Birch Components is studying whether incoming parts pass a specified inspection. Its analysts define the outcome consistently and fit a Bayesian logistic model using measurements available before inspection. They examine prior predictive behavior to see whether their assumptions imply implausible probabilities over the observed input range.
The team evaluates predictions on separately held-out batches and reports probability calibration alongside classification errors. Managers choose a review threshold based on the cost of additional inspection and missed problems. This fictional case demonstrates how inference and operational decisions can be evaluated separately; it claims no achieved reduction in defects or inspection costs.
Common misconceptions and mistakes
“The Bayesian label guarantees calibrated probabilities.” Calibration remains an empirical question influenced by data, model fit and distribution changes.
“A positive coefficient adds the same probability at every input.” It shifts log odds; its probability effect depends on the starting probability and other predictors.
“Posterior mean coefficients fully represent prediction uncertainty.” The worked example shows that substituting averages can change even the mean predictive probability.
“A credible interval for a probability is a prediction interval for an individual outcome.” Uncertainty about the probability differs from the randomness of the binary outcome itself.
“Using a prior removes the need for representative data.” A prior cannot automatically correct missing populations, measurement errors or an unsuitable likelihood.
Business use
Use this model when a clearly defined binary outcome and interpretable predictors are appropriate, and when uncertainty should be reflected in reporting or decisions. Document predictor units, prior scales, outcome definitions and the population to which predictions apply. Compare against a suitable baseline and assess performance on relevant held-out data. Report probability estimates separately from the thresholds or rules used to trigger an action, so users understand where modeling ends and decision policy begins.
People also ask
Can it model more than two categories?
Related multinomial and ordinal logistic models handle other outcome structures; they require the corresponding likelihood and assumptions.
Does it require a neural network?
No. A basic model uses a linear predictor followed by the logistic transformation.
Are priors always strong restrictions?
No. Their influence varies, but even weakly informative choices should be checked against predictor scaling and plausible outcomes.
Check your understanding
What is the draw-averaged probability in the example?
Answer: approximately 0.626932.
Why does using average coefficients give a different answer?
Answer: the logistic function is nonlinear, so averaging and transforming generally do not commute.
Does a probability near 0.63 mean the next observed outcome is 0.63?
Answer: no; the modeled outcome is binary, while the number expresses its probability.
Related terms
- Logistic regression
- Log-odds
- Prior distribution
- Posterior predictive distribution
- Probability calibration
- Bernoulli distribution
- credible interval
- decision threshold
Learn next
Convert between probabilities, odds and log odds. Then compare posterior probabilities across coefficient draws and evaluate calibration separately from the effects of a classification threshold.
More in Probabilistic machine learning
- Bayesian active learning by disagreement - Bayesian active learning by disagreement, usually abbreviated BALD, is an acquisition criterion that selects an example whose unknown label is expected to...
- Bayesian hidden Markov model - A Bayesian hidden Markov model is a probabilistic sequence model that places prior distributions on uncertain model parameters and updates them using...
- Bayesian lasso - The Bayesian lasso is a Bayesian regression approach that uses Laplace, or double-exponential, priors to shrink coefficients toward zero.
- Bayesian optimization acquisition function - A Bayesian optimization acquisition function scores possible evaluations using the current probabilistic model of an objective.
- Bayesian t-test - A Bayesian t-test is a Bayesian approach to comparing population means in a setting traditionally analyzed with a t-test.
- Behavior regularization in offline reinforcement learning - Behavior regularization in offline reinforcement learning encourages a learned decision policy to remain close to the actions represented in a fixed...
Sources
Stan User's Guide, Regression Models, logistic regression and prior specification: https://mc-stan.org/docs/stan-users-guide/regression.html Stan User's Guide, Posterior Predictive Sampling, integration and averaging over parameter draws: https://mc-stan.org/docs/stan-users-guide/posterior-prediction.html The coefficient-draw example and fictional business scenarios are original illustrations.
Previous: Bayesian linear regression Next: Bayesian model reduction