Clustering, density estimation, and anomaly detection · Hierarchical clustering · UCL017 · Algorithm
BIRCH
Compress a large numerical dataset into a clustering-feature tree and optionally cluster its leaf summaries. It is useful when the full observation matrix cannot support expensive global clustering.
In CodeSplash
A CodeSplash method runs this entry in Python and R. Set it up from the method's page.
- Hierarchical clustering Verified in Python and R
Do it in CodeSplash Run it on your own data, in Python or R.
- Availability
- Runs in CodeSplash
- Code example
- Component demo, not a trained model
- Who ran it
- CodeSplash's run and the reference's record
- CodeSplash's run
- Verified in Python and R through discover.hierarchical. The reference's example ran in Python and R here, and they agree.
- The reference's record
- Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.
Purpose
Compress a large numerical dataset into a clustering-feature tree and optionally cluster its leaf summaries. It is useful when the full observation matrix cannot support expensive global clustering.
Question / hypotheses
Which nested divisions or merges summarize the specified dissimilarity structure? This entry defines an estimation or optimization objective, not an intrinsic null/alternative hypothesis test.
Architecture / computational structure
A clustering-feature tree of additive counts/sums and optional final leaf clustering.
Assumptions
Numerical Euclidean geometry underlies the summaries. Input order and threshold affect the tree; compressed summaries may erase rare groups or fine boundaries. High dimensionality can reduce both compression and distance usefulness.
Formula / computational definition
A clustering feature stores : observation count, vector sum, and sum of squared norms. The centroid is , and squared radius is . These additive summaries allow incremental insertion, merging, and efficient memory management.
Parameters and notation
Learned or fitted quantities: CF-tree summaries, subcluster centers, and optional global labels. User-set hyperparameters/design choices: The radius threshold controls compression, branching factor controls tree fan-out, and an optional final cluster count controls the global stage. Tune these against the stated objective and stability/validation criteria; do not select settings on the final evaluation set.
Fitting, fine-tuning, and adaptation
BIRCH can incrementally insert observations into its CF-tree. Reconsider the threshold if scales or memory limits change. A global clustering of leaf summaries may need rerunning even when tree updates themselves are incremental.
How to use and calibrate
Report number and size of leaf subclusters, compression ratio, final full-data assignment cost, and sensitivity to row order. Assess both the compression stage and the downstream clustering stage.
Example application
Summarize a streaming measurement archive before global clustering. Define the reference population, measurement units, and success criterion before fitting; investigate whether discovered groups or alerts reflect the intended phenomenon.
Interpretation / pitfalls
Watch out
The reported result is conditional on the representation and objective. A stable partition can reflect nuisance structure such as batch, collection site, or missingness. Confirm the interpretation in original variables and an independent sample.
Python and R code examples
Python provides sklearn.cluster.Birch, including incremental fitting. R can bridge to it through reticulate; a custom implementation needs a real CF-tree and split logic. Computing a few sufficient statistics alone demonstrates the summary, not complete BIRCH.
Component: Clustering-feature sufficient statistics and radius. Python: executed successfully; R: not executed (Rscript unavailable). These small fixtures establish the arithmetic operation, not full-method accuracy or reproduction of paper results.
Python and R
The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.
Component demo, not a trained model — Clustering-feature sufficient statistics and radius. · needs numpy
import numpy as np
X=np.array([[0.,0.],[2.,0.],[1.,3.]])
N=len(X); LS=X.sum(0); SS=(X**2).sum()
result=np.array([N,*LS,SS,SS/N-np.sum((LS/N)**2)])
print(result)
Component demo, not a trained model — Clustering-feature sufficient statistics and radius.
X=rbind(c(0,0),c(2,0),c(1,3)); N=nrow(X); LS=colSums(X); SS=sum(X^2)
result=c(N,LS,SS,radius2=SS/N-sum((LS/N)^2))
print(result)
Sources
- Source 1scikit-learn.org
From the CodeSplash reference, entry UCL017.