#### Jay Taylor's notes

back to listing index

### Bayesian histograms for rare event classification | Hacker News

[web search]
Original source (news.ycombinator.com)
Clipped on: 2021-11-19

 A very odd method where logistic regression would have sufficed. I would have done something like`````` library(mgcv) gam(y ~ s(x), data, family = binomial) `````` to do a wiggly logistic regression, and avoid the binning issue entirely.You can do it Bayesianly if you like, but I don't see why we should discretize the data into buckets.And what am I supposed to take away from the normalized histogram?
 Yes that would probably work! GAMs are a bit of a black box to me so I find it hard to reason about them. I think my method is a bit simpler and it’s more straightforward to get uncertainties, but certainly less elegant than a smooth solution.
 Calling this Bayesian seems a bit like wishful thinking at the moment, you could just as easily have called it frequentist as the main mechanism is merging adjacent bins based on a p-value.A truly Bayesian approach would require specifying a likelihood function for the data based on the choice of bins and turning this into a posterior distribution on the choice (and number) of bins.Calculating the maximum likelihood estimate for the simplest such likelihood function (samples within a bin are uniform + the number of bins is geometrically distributed) can be done with a vaguely similar algorithm, but simply merging adjacent bins greedily is almost certainly biasing the result right now.
 I basically determine p via Bayesian inference within every bin (via a conjugate beta prior for p which gives a beta posterior). If that’s not Bayesian then I don’t know what is :)Yes the pruning can be done with a frequentist method too. Yes you can come up with smarter / more statistically sound ways to construct these binnings. Do they work on >1e9 data points?
 Interesting. You've invented something like the Optional Polya Tree [1], except from a bottom up instead of top down construction.
 While I haven't tried it out yet, I have to say I very much like the idea, and the article is very clear and well-written. Nicely done!

Search: