class sklearn.cluster.Birch(threshold=0.5, branching_factor=50, n_clusters=3, compute_labels=True, copy=True)
[source]
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.
Parameters: |
|
---|---|
Attributes: |
|
The tree data structure consists of nodes with each node consisting of a number of subclusters. The maximum number of subclusters in a node is determined by the branching factor. Each subcluster maintains a linear sum, squared sum and the number of samples in that subcluster. In addition, each subcluster can also have a node as its child, if the subcluster is not a member of a leaf node.
For a new point entering the root, it is merged with the subcluster closest to it and the linear sum, squared sum and the number of samples of that subcluster are updated. This is done recursively till the properties of the leaf node are updated.
>>> from sklearn.cluster import Birch >>> X = [[0, 1], [0.3, 1], [-0.3, 1], [0, -1], [0.3, -1], [-0.3, -1]] >>> brc = Birch(branching_factor=50, n_clusters=None, threshold=0.5, ... compute_labels=True) >>> brc.fit(X) Birch(branching_factor=50, compute_labels=True, copy=True, n_clusters=None, threshold=0.5) >>> brc.predict(X) array([0, 0, 0, 1, 1, 1])
fit (X[, y]) | Build a CF Tree for the input data. |
fit_predict (X[, y]) | Performs clustering on X and returns cluster labels. |
fit_transform (X[, y]) | Fit to data, then transform it. |
get_params ([deep]) | Get parameters for this estimator. |
partial_fit ([X, y]) | Online learning. |
predict (X) | Predict data using the centroids_ of subclusters. |
set_params (**params) | Set the parameters of this estimator. |
transform (X) | Transform X into subcluster centroids dimension. |
__init__(threshold=0.5, branching_factor=50, n_clusters=3, compute_labels=True, copy=True)
[source]
fit(X, y=None)
[source]
Build a CF Tree for the input data.
Parameters: |
|
---|
fit_predict(X, y=None)
[source]
Performs clustering on X and returns cluster labels.
Parameters: |
|
---|---|
Returns: |
|
fit_transform(X, y=None, **fit_params)
[source]
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: |
|
---|---|
Returns: |
|
get_params(deep=True)
[source]
Get parameters for this estimator.
Parameters: |
|
---|---|
Returns: |
|
partial_fit(X=None, y=None)
[source]
Online learning. Prevents rebuilding of CFTree from scratch.
Parameters: |
|
---|
predict(X)
[source]
Predict data using the centroids_
of subclusters.
Avoid computation of the row norms of X.
Parameters: |
|
---|---|
Returns: |
|
set_params(**params)
[source]
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter>
so that it’s possible to update each component of a nested object.
Returns: |
|
---|
transform(X)
[source]
Transform X into subcluster centroids dimension.
Each dimension represents the distance from the sample point to each cluster centroid.
Parameters: |
|
---|---|
Returns: |
|
sklearn.cluster.Birch
© 2007–2018 The scikit-learn developers
Licensed under the 3-clause BSD License.
http://scikit-learn.org/stable/modules/generated/sklearn.cluster.Birch.html