Really Fast Bayesian Linear Regression
A little performance vignette. I measured the draw and update of a Bayesian linear regression against how fast one core can actually go, and found which scipy routines get there and which don’t.
7 items found
A little performance vignette. I measured the draw and update of a Bayesian linear regression against how fast one core can actually go, and found which scipy routines get there and which don’t.
My old churn model measured how surprising a user’s silence was against their own history. That’s a real question with a real answer, but it isn’t churn risk: it flagged regulars who took a week off and ignored light users who’d quietly stopped. It passed every backtest for two years; a confused user in a focus group is what caught it. The replacement is the table banks use for late accounts – bin users by how long they’ve been gone and how much they normally use the product, count who came back – with the same empirical Bayes shrinkage as before, pointed at the right quantity this time.
Wen et al. show two forecasters with identical marginal predictions can make arbitrarily different decisions. A disjoint contextual bandit (one model per arm) is exactly their independence forecaster. In conjugate linear models the joint is exact and free, and partial pooling through a shared component gets it back.
If you’re running a Bayesian model in a non-stationary environment, you need to forget old data. The obvious approach – scale the precision matrix by a constant – has a failure mode called covariance windup. This post works through three forgetting rules, ending with one borrowed from adaptive control that dominates the others.
I probably overuse the normal-inverse-gamma posterior. Every time I build a bandit system, every time I need uncertainty quantification for sequential decisions, I end up back at conjugate linear regression.
Suppose you’re choosing a continuous value x and observing a noisy reward y. The reward depends on x through some unknown function f(x), and you’re making decisions repeatedly—learning as you go. This post explores how to build scalable Bayesian models for this problem using principled approximations.
Update, August 2026: I no longer stand behind this approach. The model below measures how surprising a user’s silence is against their own history, and in production that turned out to flag the users least likely to leave. I’ve written up what went wrong and what replaced it in Churn Risk Is a Conditional Rate. The original post is left as written.