Skip to content

Implement Bayesian logistic regression #1917

Description

@MaxHalford

Motivation

linear_model.BayesianLinearRegression maintains a full Gaussian posterior over the weights, which gives calibrated predictive uncertainty (predict_one(..., with_dist=True)) and makes it a natural fit for downstream uses like bandit.LinUCB. There is no classification counterpart yet.

A streaming Bayesian logistic regression would provide the same benefits for binary classification: a posterior over the weights, well-calibrated probabilities, and uncertainty estimates usable for Thompson-sampling / UCB-style bandits.

Approach

The logistic likelihood is non-Gaussian, so there's no exact conjugate update. The usual streaming options:

  • Laplace approximation / Online Newton — maintain a Gaussian posterior, update mean + precision per observation using the gradient and Hessian of the log-likelihood (cf. the approach behind linear_model.AdPredictor, which already keeps a Gaussian belief per weight via probit ADF).
  • Assumed-density filtering (ADF) — moment-match after each observation (this is essentially what AdPredictor does for the probit link).
  • Variational updates (e.g. Jaakkola–Jordan bound) for a logit link.

Worth surveying how this relates to the existing AdPredictor (probit, diagonal covariance) before deciding on the link function and covariance structure (diagonal vs full).

Notes

  • Should implement Classifier/MiniBatchClassifier and expose calibrated predict_proba_one, ideally with access to predictive uncertainty.
  • Reuse the NumPy-backed state + Sherman-Morrison machinery from the recently reworked BayesianLinearRegression where applicable.
  • Related: BayesianLinearRegression learn_many work in Add learn_many to BayesianLinearRegression #1916.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions