Class: Birch

Implements the BIRCH clustering algorithm.

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.

Read more in the User Guide.

Python Reference

Constructors

new Birch()

new Birch(opts?): Birch

Parameters

ParameterTypeDescription
opts?object-
opts.branching_factor?numberMaximum number of CF subclusters in each node. If a new samples enters such that the number of subclusters exceed the branching_factor then that node is split 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.
opts.compute_labels?booleanWhether or not to compute labels for each fit.
opts.copy?booleanWhether or not to make a copy of the given data. If set to false, the initial data will be overwritten.
opts.n_clusters?numberNumber of clusters after the final clustering step, which treats the subclusters from the leaves as new samples.
opts.threshold?numberThe radius of the subcluster obtained by merging a new sample and the closest subcluster should be lesser than the threshold. Otherwise a new subcluster is started. Setting this value to be very low promotes splitting and vice-versa.

Returns Birch

Defined in generated/cluster/Birch.ts:25

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/cluster/Birch.ts:23
_isInitializedbooleanfalsegenerated/cluster/Birch.ts:22
_pyPythonBridgeundefinedgenerated/cluster/Birch.ts:21
idstringundefinedgenerated/cluster/Birch.ts:18
optsanyundefinedgenerated/cluster/Birch.ts:19

Accessors

dummy_leaf_

Get Signature

get dummy_leaf_(): Promise<any>

Start pointer to all the leaves.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:485


feature_names_in_

Get Signature

get feature_names_in_(): Promise<ArrayLike>

Names of features seen during fit. Defined only when X has feature names that are all strings.

Returns Promise<ArrayLike>

Defined in generated/cluster/Birch.ts:603


labels_

Get Signature

get labels_(): Promise<ArrayLike>

Array of labels assigned to the input data. if partial_fit is used instead of fit, they are assigned to the last batch of data.

Returns Promise<ArrayLike>

Defined in generated/cluster/Birch.ts:558


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/cluster/Birch.ts:580


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/cluster/Birch.ts:65


root_

Get Signature

get root_(): Promise<any>

Root of the CFTree.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:463


subcluster_centers_

Get Signature

get subcluster_centers_(): Promise<ArrayLike>

Centroids of all subclusters read directly from the leaves.

Returns Promise<ArrayLike>

Defined in generated/cluster/Birch.ts:508


subcluster_labels_

Get Signature

get subcluster_labels_(): Promise<ArrayLike>

Labels assigned to the centroids of the subclusters after they are clustered globally.

Returns Promise<ArrayLike>

Defined in generated/cluster/Birch.ts:533

Methods

dispose()

dispose(): Promise<void>

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Returns Promise<void>

Defined in generated/cluster/Birch.ts:116


fit()

fit(opts): Promise<any>

Build a CF Tree for the input data.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeInput data.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:133


fit_predict()

fit_predict(opts): Promise<ArrayLike>

Perform clustering on X and returns cluster labels.

Parameters

ParameterTypeDescription
optsobject-
opts.kwargs?anyArguments to be passed to fit.
opts.X?ArrayLike[]Input data.
opts.y?anyNot used, present for API consistency by convention.

Returns Promise<ArrayLike>

Defined in generated/cluster/Birch.ts:170


fit_transform()

fit_transform(opts): Promise<any[]>

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters

ParameterTypeDescription
optsobject-
opts.fit_params?anyAdditional fit parameters.
opts.X?ArrayLike[]Input samples.
opts.y?ArrayLikeTarget values (undefined for unsupervised transformations).

Returns Promise<any[]>

Defined in generated/cluster/Birch.ts:214


get_feature_names_out()

get_feature_names_out(opts): Promise<any>

Get output feature names for transformation.

The feature names out will prefixed by the lowercased class name. For example, if the transformer outputs 3 features, then the feature names out are: \["class_name0", "class_name1", "class_name2"\].

Parameters

ParameterTypeDescription
optsobject-
opts.input_features?anyOnly used to validate feature names with the names seen in fit.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:258


get_metadata_routing()

get_metadata_routing(opts): Promise<any>

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Parameters

ParameterTypeDescription
optsobject-
opts.routing?anyA MetadataRequest encapsulating routing information.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:292


init()

init(py): Promise<void>

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Parameters

ParameterType
pyPythonBridge

Returns Promise<void>

Defined in generated/cluster/Birch.ts:78


partial_fit()

partial_fit(opts): Promise<any>

Online learning. Prevents rebuilding of CFTree from scratch.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeInput data. If X is not provided, only the global clustering step is done.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:324


predict()

predict(opts): Promise<any>

Predict data using the centroids_ of subclusters.

Avoid computation of the row norms of X.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeInput data.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:363


set_output()

set_output(opts): Promise<any>

Set output container.

See Introducing the set_output API for an example on how to use the API.

Parameters

ParameterTypeDescription
optsobject-
opts.transform?"default" | "pandas" | "polars"Configure output of transform and fit_transform.

Returns Promise<any>

Defined in generated/cluster/Birch.ts:397


transform()

transform(opts): Promise<ArrayLike>

Transform X into subcluster centroids dimension.

Each dimension represents the distance from the sample point to each cluster centroid.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeInput data.

Returns Promise<ArrayLike>

Defined in generated/cluster/Birch.ts:431