BIRCH

From HandWiki
Short description: Clustering using tree-based data aggregation

BIRCH (balanced iterative reducing and clustering using hierarchies) is an unsupervised data mining algorithm used to perform hierarchical clustering over particularly large data-sets.[1] With modifications it can also be used to accelerate k-means clustering and Gaussian mixture modeling with the expectation–maximization algorithm.[2] An advantage of BIRCH is its ability to incrementally and dynamically cluster incoming, multi-dimensional metric data points in an attempt to produce the best quality clustering for a given set of resources (memory and time constraints). In most cases, BIRCH only requires a single scan of the database.

Its inventors claim BIRCH to be the "first clustering algorithm proposed in the database area to handle 'noise' (data points that are not part of the underlying pattern) effectively",[1] beating DBSCAN by two months. The BIRCH algorithm received the SIGMOD 10 year test of time award in 2006.[3]

Problem with previous methods

Previous clustering algorithms performed less effectively over very large databases and did not adequately consider the case wherein a data-set was too large to fit in main memory. As a result, there was a lot of overhead maintaining high clustering quality while minimizing the cost of additional IO (input/output) operations. Furthermore, most of BIRCH's predecessors inspect all data points (or all currently existing clusters) equally for each 'clustering decision' and do not perform heuristic weighting based on the distance between these data points.

Advantages with BIRCH

It is local in that each clustering decision is made without scanning all data points and currently existing clusters. It exploits the observation that the data space is not usually uniformly occupied and not every data point is equally important. It makes full use of available memory to derive the finest possible sub-clusters while minimizing I/O costs. It is also an incremental method that does not require the whole data set in advance.

Algorithm

The BIRCH algorithm takes as input a set of N data points, represented as real-valued vectors, and a desired number of clusters K. It operates in four phases, the second of which is optional.

The first phase builds a clustering feature ([math]\displaystyle{ CF }[/math]) tree out of the data points, a height-balanced tree data structure, defined as follows:

  • Given a set of N d-dimensional data points, the clustering feature [math]\displaystyle{ CF }[/math] of the set is defined as the triple [math]\displaystyle{ CF = (N,\overrightarrow{LS},SS) }[/math], where
    • [math]\displaystyle{ \overrightarrow{LS} = \sum_{i=1}^N \overrightarrow{X_i} }[/math] is the linear sum.
    • [math]\displaystyle{ SS = \sum_{i=1}^N (\overrightarrow{X_i})^2 }[/math] is the square sum of data points.
  • Clustering features are organized in a CF tree, a height-balanced tree with two parameters:[clarification needed] branching factor [math]\displaystyle{ B }[/math] and threshold [math]\displaystyle{ T }[/math]. Each non-leaf node contains at most [math]\displaystyle{ B }[/math] entries of the form [math]\displaystyle{ [CF_i,child_i] }[/math], where [math]\displaystyle{ child_i }[/math] is a pointer to its [math]\displaystyle{ i }[/math]th child node and [math]\displaystyle{ CF_i }[/math] the clustering feature representing the associated subcluster. A leaf node contains at most [math]\displaystyle{ L }[/math] entries each of the form [math]\displaystyle{ [CF_i] }[/math] . It also has two pointers prev and next which are used to chain all leaf nodes together. The tree size depends on the parameter [math]\displaystyle{ T }[/math]. A node is required to fit in a page of size [math]\displaystyle{ P }[/math]. [math]\displaystyle{ B }[/math] and [math]\displaystyle{ L }[/math] are determined by [math]\displaystyle{ P }[/math]. So [math]\displaystyle{ P }[/math] can be varied for performance tuning. It is a very compact representation of the dataset because each entry in a leaf node is not a single data point but a subcluster.

In the second step, the algorithm scans all the leaf entries in the initial [math]\displaystyle{ CF }[/math] tree to rebuild a smaller [math]\displaystyle{ CF }[/math] tree, while removing outliers and grouping crowded subclusters into larger ones. This step is marked optional in the original presentation of BIRCH.

In step three an existing clustering algorithm is used to cluster all leaf entries. Here an agglomerative hierarchical clustering algorithm is applied directly to the subclusters represented by their [math]\displaystyle{ CF }[/math] vectors. It also provides the flexibility of allowing the user to specify either the desired number of clusters or the desired diameter threshold for clusters. After this step a set of clusters is obtained that captures major distribution pattern in the data. However, there might exist minor and localized inaccuracies which can be handled by an optional step 4. In step 4 the centroids of the clusters produced in step 3 are used as seeds and redistribute the data points to its closest seeds to obtain a new set of clusters. Step 4 also provides us with an option of discarding outliers. That is a point which is too far from its closest seed can be treated as an outlier.

Calculations with the clustering features

Given only the clustering feature [math]\displaystyle{ CF = [N, \overrightarrow{LS}, SS] }[/math], the same measures can be calculated without the knowledge of the underlying actual values.

  • Centroid: [math]\displaystyle{ \overrightarrow{C} = \frac{\sum_{i=1}^N \overrightarrow{X_i}}{N} = \frac{\overrightarrow{LS}}{N} }[/math]
  • Radius: [math]\displaystyle{ R = \sqrt{\frac{ \sum_{i=1}^N (\overrightarrow{X_i} - \overrightarrow{C})^2}{N}} = \sqrt{\frac{N \cdot \overrightarrow{C}^2 + SS - 2 \cdot \overrightarrow{C} \cdot \overrightarrow{LS}}{N}} = \sqrt{\frac{SS}{N} - (\frac{\overrightarrow{LS}}{N})^2} }[/math]
  • Average Linkage Distance between clusters [math]\displaystyle{ CF_1 = [N_1, \overrightarrow{LS_1}, SS_1] }[/math] and [math]\displaystyle{ CF_2 = [N_2, \overrightarrow{LS_2}, SS_2] }[/math]:[math]\displaystyle{ D_2 = \sqrt{\frac{\sum_{i=1}^{N_1} \sum_{j=1}^{N_2} (\overrightarrow{X_i} - \overrightarrow{Y_j})^2}{N_1 \cdot N_2}} = \sqrt{\frac{N_1 \cdot SS_2 + N_2 \cdot SS_1 - 2 \cdot \overrightarrow{LS_1} \cdot \overrightarrow{LS_2}}{N_1 \cdot N_2}} }[/math]

In multidimensional cases the square root should be replaced with a suitable norm.

Numerical issues in BIRCH clustering features

Unfortunately, there are numerical issues associated with the use of the term [math]\displaystyle{ SS }[/math] in BIRCH. When subtracting [math]\displaystyle{ \frac{SS}{N}-\big(\frac{\vec{LS}}{N}\big)^2 }[/math] or similar in the other distances such as [math]\displaystyle{ D_2 }[/math], catastrophic cancellation can occur and yield a poor precision, and which can in some cases even cause the result to be negative (and the square root then become undefined).[2] This can be resolved by using BETULA cluster features [math]\displaystyle{ CF=(N,\mu,S) }[/math] instead, which store the count [math]\displaystyle{ N }[/math], mean [math]\displaystyle{ \mu }[/math], and sum of squared deviations instead based on numerically more reliable online algorithms to calculate variance. For these features, a similar additivity theorem holds. When storing a vector respectively a matrix for the squared deviations, the resulting BIRCH CF-tree can also be used to accelerate Gaussian Mixture Modeling with the expectation–maximization algorithm, besides k-means clustering and hierarchical agglomerative clustering.

Notes

  1. 1.0 1.1 Zhang, T.; Ramakrishnan, R.; Livny, M. (1996). "BIRCH: an efficient data clustering method for very large databases". pp. 103–114. doi:10.1145/233269.233324. 
  2. 2.0 2.1 Lang, Andreas; Schubert, Erich (2020), "BETULA: Numerically Stable CF-Trees for BIRCH Clustering" (in en), Similarity Search and Applications: pp. 281–296, doi:10.1007/978-3-030-60936-8_22, ISBN 978-3-030-60935-1, http://link.springer.com/10.1007/978-3-030-60936-8_22, retrieved 2021-01-16 
  3. "2006 SIGMOD Test of Time Award". http://www.sigmod.org/sigmod-awards/citations/2006-sigmod-test-of-time-award-1.