Skip to contents

It is a memory-efficient, online-learning algorithm provided as an alternative to MiniBatchKMeans. It constructs a tree data structure with the cluster centroids being read off the leaf. These can be either the final cluster centroids or can be provided as input to another clustering algorithm such as AgglomerativeClustering. This is a wrapper around the Python class sklearn.cluster.Birch.


Super classes

rgudhi::PythonClass -> rgudhi::SKLearnClass -> rgudhi::BaseClustering -> Birch


Public methods

Inherited methods

Method new()

The Birch class constructor.


  threshold = 0.5,
  branching_factor = 50L,
  n_clusters = 3L,
  compute_labels = TRUE,
  copy = TRUE



A numeric value specifying the upper bound of the radius of the subcluster obtained by merging a new sample and the closest subcluster. Otherwise a new subcluster is started. Setting this value to be very low promotes splitting and vice-versa. Defaults to 0.5.


An integer value specifying the maximum number of CF subclusters in each node. If a new sample enters such that the number of subclusters exceeds the branching_factor then that node is splitted into two nodes with the subclusters redistributed in each. The parent subcluster of that node is removed and two new subclusters are added as parents of the 2 split nodes.


Either an integer value or an object of class BaseClustering specifying the number of clusters after the final clustering step, which treats the subclusters from the leaves as new samples.

  • NULL: the final clustering step is not performed and the subclusters are returned as they are;

  • an object of class BaseClustering: the model is fit treating the subclusters as new samples and the initial data is mapped to the label of the closest subcluster;

  • integer value: the model fit is AgglomerativeClustering with n_clusters set to be equal to the integer value. Defaults to 3L.


A boolean value specifying whether to compute labels for each fit. Defaults to TRUE.


A boolean value specifying whether to make a copy of the given data. If set to FALSE, the initial data will be overwritten. Defaults to TRUE.


An object of class Birch.

Method clone()

The objects of this class are cloneable with this method.


Birch$clone(deep = FALSE)



Whether to make a deep clone.


if (FALSE) { # reticulate::py_module_available("sklearn.cluster")
cl <- Birch$new()