Contents
06Dirichlet process mixtures: let the data choose K
6.1The stick-breaking prior
A GMM still needs K. A Bayesian alternative is to allow infinitely many clusters but to put a prior on the weights that strongly prefers only a few to be used. The stick-breaking construction of the Dirichlet process (Ferguson, 1973; Sethuraman, 1994) does this. Take a stick of length one. Break off a random fraction \beta_1 for cluster 1; from the remaining length 1-\beta_1 break off a fraction \beta_2 for cluster 2; and so on:
The weights sum to one, and since each piece takes a fraction of what is left, they shrink geometrically on average. A \mathrm{Beta}(1,\alpha) variable has mean 1/(1+\alpha), and the \beta_k are independent, so
The concentration parameter \alpha controls how eager the model is to open new clusters (Figure 5a). With \alpha=1 the expected weights are \frac12,\frac14,\frac18,\dots; with \alpha=5 they are 0.167, 0.139, 0.116,\dots, spread over many clusters; with the video’s \alpha=0.05 the first piece takes 95\% of the stick on average.
6.2How many clusters does the prior expect?
The same prior can be described without sticks, by the Chinese restaurant process: customers (data points) enter one by one; the next customer sits at an existing table with probability proportional to the number of people already there, and at a new table with probability proportional to \alpha. With tables of 5, 3 and 1 people and \alpha=1, the tenth customer joins them with probabilities 0.5, 0.3 and 0.1, or opens a new table with probability 0.1. The rich get richer, which is why a few large clusters dominate. Customer i opens a new table with probability \alpha/(\alpha+i-1), so the expected number of occupied tables after n customers is
It grows only logarithmically with n. For n=360 points it is 1.32 for \alpha=0.05, 6.46 for \alpha=1 and 21.96 for \alpha=5 (the approximation gives 5.89 and 21.45 for the last two). The prior expectation is not a hard limit: data that need more clusters get them, at a price.
6.3Fitting in practice
Exact Bayesian inference is intractable, so the infinite mixture is truncated at a generous number of components and fitted by variational inference (Blei and Jordan, 2006), a Bayesian cousin of EM that alternates between soft assignments and updates of the distributions of the weights, means and covariances; scikit-learn’s BayesianGaussianMixture implements it. Components that explain no data are pushed toward zero weight by the prior. In the video’s scene (Figure 5b,c), 360 points from three groups are fitted with ten components and \alpha=0.05. After 10 iterations 8 components still have more than 1\% of the weight, after 20 there are 6, after 40 there are 4, and from about iteration 80 only three survive, with weights 0.331, 0.333 and 0.325; the clusters agree with the generating groups almost perfectly (\mathrm{ARI}=0.99). Note that the prior alone expected only 1.32 clusters: the data overruled it.
Pause and think. Does a Dirichlet process mixture find the “true” number of clusters?
Show the answer
Not automatically. The number it finds depends on \alpha, on the priors for the covariances and on the model: if the real clusters are not Gaussian, it may use several components for one curved or skewed cluster. It replaces the choice of K by the gentler choice of \alpha, and gives uncertainty about K for free.