Undoing Bad Merges in Bayesian Hierarchical Clustering by Exact Subtree Regrafting

Bayesian hierarchical clustering builds a tree bottom-up. At each step it merges the pair of groups that a statistical test says most plausibly came from the same generating distribution. It stops when no merge is supported by the evidence, so the user never has to pick a distance threshold. Like every bottom-up method, though, it never revisits a decision. A merge made early, from a handful of noisy points, becomes a permanent premise for every later merge, and the error spreads upward through the tree. Distance-based clustering has known fixes for this: algorithms that cut out a misplaced subtree and reattach it somewhere better. Those fixes are tied to Euclidean geometry or to ad-hoc similarity scores. The probabilistic methods that do avoid lock-in, such as variational inference used in speaker diarization, get there by throwing the tree away.

This note proposes a repair move for the probabilistic setting itself. The move cuts out any subtree and scores every place it could be reattached, all at once, using the same quantity Bayesian hierarchical clustering already optimizes: the probability of the data under the tree, also called the model evidence. It then hill-climbs the tree on that score. The core observation is that this tree score is computed recursively from per-node summaries of the data that can be added and subtracted. Moving a subtree therefore changes the score only along two paths from the leaves to the root. The question is whether this cheap, exact, likelihood-driven repair recovers hierarchies that greedy construction gets wrong, at a cost close to greedy construction, and without giving up the tree.

Core Claim

Bayesian hierarchical clustering (BHC) works with conjugate models, meaning priors chosen so the data likelihood integrates out in closed form. For such models, the change in the tree's log evidence caused by pruning a subtree $S$ and regrafting it as the sibling of a node $v$ can be computed exactly. Only the nodes on the root paths of the old and new attachment points need to be updated. Each node's merged-hypothesis likelihood depends on the data only through additive summaries (counts, sums, scatter matrices), so the update amounts to subtracting the summaries of $S$ along one path and adding them along the other. At each node $a$, BHC's evidence has the form

$$p(D_a \mid T_a) = \pi_a\, p(D_a \mid H_1) + (1-\pi_a) \prod_{c \in \mathrm{ch}(a)} p(D_c \mid T_c).$$

Here $D_a$ is the data under $a$, $T_a$ is its subtree, $H_1$ is the hypothesis that all of $D_a$ shares one component, and $\pi_a$ is the prior probability of that hypothesis. When $\pi_a$ is held fixed, this expression is increasing and affine in each child's evidence. That allows a single bottom-up pass to find the best regraft location for $S$ over all $O(n)$ candidates, using $O(n)$ closed-form marginal-likelihood evaluations.

This is the probabilistic counterpart of the one-pass graft of An Iterative Improvement Procedure for Hierarchical Clustering. That paper's efficiency comes from the bias–variance decomposition of squared Euclidean distance and, as the research file notes, does not carry over to likelihoods. Under the Dirichlet-process version of $\pi_a$, which depends on subtree sizes through a normalizer $d_a$ defined recursively along the same paths, the single-max argument no longer holds exactly. In that case we fall back to exact path-wise scoring at $O(n \cdot \text{depth})$ per pruned subtree. That is $O(n \log n)$ for balanced trees. We will measure how often the fixed-$\pi$ pass picks a different location than the exact score.

The claim is that interleaving these exact regrafts with greedy BHC (and with Bayesian Rose Trees, adding a "split" move) gives three things. It raises the tree's lower bound on the marginal likelihood. It raises dendrogram purity on data with order-sensitive or non-spherical structure. It does both at a small constant factor over greedy cost, and it beats sampling-based tree search run with the same compute.

Relation to Prior Work

Three papers motivate the gap by showing that tree repair helps but is unavailable in the probabilistic setting. Tree-Based Inference for Dirichlet Process Mixtures detaches subtrees from the BHC tree to enumerate alternative trees. It sums their contributions to tighten the marginal-likelihood bound, but never commits to a better tree or iterates. We turn that operation into an exactly scored hill-climbing move. Kauchak and Dasgupta's hill-climber shows that graft moves polish an average-linkage tree, reporting nearly 20% lower $k$-means cost at some levels on yeast expression data. Their objective is geometric. GRINCH, from Scalable Hierarchical Clustering with Tree Grafting, adds rotate and graft moves to incremental clustering under arbitrary pairwise linkages and proves order invariance under a separability condition. It keeps no model evidence. We keep the evidence and borrow its idea of triggering repairs during construction rather than only afterwards.

Two papers constrain the design. Interactive Bayesian Hierarchical Clustering already uses prune-and-regraft moves, but inside a Markov chain Monte Carlo (MCMC) sampler, a method that explores tree space by random proposals, driven by user-supplied triplet constraints. That makes it the closest existing mechanism. The difference is that we score all regraft targets exactly and deterministically with no oracle, whereas a sampler proposes them at random. Whether that difference matters is an empirical question we test directly. Exact and approximate hierarchical clustering using A* finds globally optimal trees but is exact only up to about 30 points, and needs approximation up to 500. Global search is therefore not the scalable route, and its exact solutions serve us as ground-truth optima on small instances.

Finally, the speech work of Bayesian HMM Based x-Vector Clustering for Speaker Diarization and Estimation of the Number of Speakers with Variational Bayesian PLDA escapes greedy merging by abandoning the tree for soft flat assignments. It supplies our hardest applied comparison.

Research Program

We build Regraft-BHC in three layers. The first layer is the exact move: prune a subtree, subtract its summaries along its root path, and score all regraft targets. We implement this for four conjugate families: Gaussian with Normal-Inverse-Wishart prior, multinomial with Dirichlet prior, Bernoulli with Beta prior, and the two-covariance Gaussian model of probabilistic linear discriminant analysis (PLDA) used for speaker embeddings.

The second layer is scheduling. Each internal node carries BHC's merge posterior. After every greedy merge, we prune and rescore only the subtrees whose merge posterior was lowest when created, or whose sibling's evidence changed most. After construction, we run sweeps until no move increases the evidence. We also run the alternative where regrafting happens only after construction, to test whether interleaving matters.

The third layer extends the method to rose trees. A split move detaches one child of a multi-way node and regrafts it. This addresses the documented failure of Bayesian Rose Trees, which can flatten a spurious merge but cannot separate two wrongly combined groups.

Alongside the algorithm, we study two things analytically. One is when the fixed-$\pi$ single pass is exact. The other is whether every fixed point of the move set is robust to the order in which ties are broken in the initial greedy run. We will study that robustness empirically by perturbing tie-breaks, and we do not promise a GRINCH-style theorem.

Baselines

The naive reference is greedy BHC itself, and greedy Bayesian Rose Trees where non-binary trees apply. Both are run with the same prior hyperparameters chosen once on held-out data. Any improvement in evidence or purity over them is the minimum bar.

The strongest probabilistic competitor is an unconstrained version of the prune-and-regraft MCMC sampler of Vikram and Dasgupta. It runs on the same BHC evidence, uses random regraft proposals, and starts from the greedy tree. We also run a simulated-annealing variant of it. All are given the same wall-clock budget and the same number of marginal-likelihood evaluations as Regraft-BHC. Beating it means a higher evidence and purity at equal evaluations. Matching it at much lower cost would count as a partial win.

The Euclidean competitor is Kauchak–Dasgupta grafting, with results re-scored by BHC evidence. It is the most likely to match us on Gaussian data. The meaningful test is on multinomial and Bernoulli data, where its geometry is misspecified.

We also include three further comparisons. The alternative-tree bound of Xu et al. tests whether committing to a better tree beats averaging over alternatives. GRINCH with average linkage tests whether the likelihood adds anything over linkage-based repair. GRINCH reports 1.0 dendrogram purity on synthetic chain data against roughly 0.85 for other incremental methods. Exact A* gives the global optimum on instances with $n \le 30$.

Two ablations isolate the key ingredient. The first replaces exact batched scoring with uniformly sampled regraft targets at equal evaluations. The second disables interleaving.

For diarization, the reference points are those reported in Bayesian HMM Based x-Vector Clustering for Speaker Diarization on DIHARD I evaluation. Agglomerative clustering reaches 25.23% diarization error rate (DER), variational clustering on x-vectors 24.26%, and the version with a second refinement stage 23.43%. Our comparison targets the 24.26% x-vector-only system, since we use no refinement stage.

Why not just…?

Why not just run MCMC over trees? It is the principled answer and the real threat. Zero-temperature hill-climbing is a degenerate sampler, and with enough compute MCMC should find trees at least as good. Our bet is that exact batched scoring of all $O(n)$ targets per pruned subtree finds improving moves far faster than random proposals. The Interactive Bayesian Hierarchical Clustering authors already note that MCMC mixing on tree space limits scalability. The equal-evaluation comparison in the baselines settles this question. If MCMC matches us at equal cost, the contribution reduces to a better proposal distribution for MCMC, and we would report it as such.

Why not just run flat variational inference on a Dirichlet process mixture? That method avoids hard merges but outputs no hierarchy. Xu et al. also report that the tree bound is almost always tighter than variational and collapsed-variational bounds on Iris, Abalone, Wine and Newsgroups, and that the tree method gives better predictive likelihood. Diarization is where flat variational inference is strongest. There we compare against it directly, and we accept that matching 24.26% DER while also returning a tree is the realistic success criterion.

Why not just restart greedy BHC with perturbed tie-breaks or bootstrap resamples and keep the best-evidence tree? This is cheap and embarrassingly parallel. We run it with the same evaluation budget. Restarts sample new greedy trajectories but cannot fix an early merge that the data consistently favor locally. Chain-like synthetic data is designed to expose exactly this case.

Why not just polish with Euclidean grafting? On Gaussian data with isotropic noise this may be nearly equivalent, and if so we will say so. The claim of the method rests on non-Euclidean likelihoods, namely multinomial text counts and binary features. On that data, squared-distance grafting optimizes the wrong objective.

Proposed Experiments

On synthetic data we run Gaussian mixtures, GRINCH-style chains, and planted hierarchies with injected early-merge errors at controlled rates. We measure dendrogram purity, log evidence, and the fraction of planted errors repaired, over 20 random orderings.

On the Iris, Wine, 600-point Abalone and 20 Newsgroups datasets used by Xu et al. and in Bayesian Rose Trees, and on the UCI Spambase and Zoo data used in those two papers and in the interactive work, we report the marginal-likelihood lower bound, held-out predictive log-likelihood, dendrogram purity against class labels, and runtime. No numerical values for BHC or BRT on these datasets were found in the material, so we rerun them. On subsets with $n \le 30$ we report the gap to the A* optimum.

The applied test clusters PLDA-scored x-vectors on DIHARD I with oracle speech activity labels, so that clustering errors are isolated. We read the flat partition off the final tree using BHC's native evidence-based stopping rule.

The decisive checks are these. Regraft-BHC must beat MCMC at equal marginal-likelihood evaluations on evidence and purity. It must beat Euclidean grafting on the multinomial and Bernoulli datasets. It must close most of the gap between greedy BHC and the A* optimum on small instances. On DIHARD I, it should land between agglomerative clustering's 25.23% and variational clustering's 24.26% DER or better, while still returning a hierarchy. If the sampled-target ablation performs as well as exact scoring, the batching trick is not what drives the gains, and the proposal should be reframed around the move set alone.