Approximate the posterior of a logistic regression model with a Gaussian and use it to make predictions.
Prior: on every weight (no separate bias handling). Likelihood: .
Implement:
laplace_logreg(X, y, prior_var, n_iter=50): find the MAP estimate of the log posterior by Newton's method from (run n_iter steps or stop early once the step norm is below ), and return (w_map, Sigma) with
evaluated at .predictive(X_test, w_map, Sigma, method, n_samples=1000, seed=0): return for each test row.
"plugin": ."mc": create a generator with NumPy's default_rng seeded by seed, draw one standard_normal array of shape (n_samples, D) whose rows are , set where is the lower Cholesky factor of , and average over the samples."probit": with , and .Return 1-D arrays.