Path: blob/master/notebooks/book2/15/adf_logistic_regression_demo.ipynb
1192 views
Online Logistic Regression using ADF
Online training of a logistic regression model using Assumed Density Filtering (ADF).
We compare the ADF result with Laplace approximation of the posterior.
For further details, see the ADF paper: O. Zoeter, "Bayesian Generalized Linear Models in a Terabyte World," 2007 5th International Symposium on Image and Signal Processing and Analysis, 2007, pp. 435-440, doi: 10.1109/ISPA.2007.4383733.
Authors: Peter G. Chang (@petergchang), Gerardo Durán-MartÃn (@gerdm)
0. Imports
##1. Simulation and Plotting
We generate a reasonable 2d binary classification data.
Next, we define a function that visualizes the 2d posterior predictive distribution.
Let's look at our binary data in 2d.
Let us define a grid on which we compute the predictive distribution.
Next, we define a function to that returns the posterior predictive probability for each point in grid.
Also, we define a function that prints and plots the final ADF estimate of the weights.
Finally, we define a function that plots the convergence of filtered estimates to Laplace batch estimate.
##2. Laplace Estimate
We compute the Laplace-approximation posterior for comparison.
##3. ADF Estimates
First we define the sigma-point numerical integration to be used by the update step for ADF.
Next, we can construct a 1d logistic regression ADF.
##4. Inference over Time
Finally, we will look at the convergence of the ADF-inferred weights to the Laplace batch estimate.