DocumentationClassesAgglomerativeClustering

Class: AgglomerativeClustering

Agglomerative Clustering.

Recursively merges pair of clusters of sample data; uses linkage distance.

Read more in the User Guide.

Python Reference

Constructors

new AgglomerativeClustering()

new AgglomerativeClustering(opts?): AgglomerativeClustering

Parameters

ParameterTypeDescription
opts?object-
opts.compute_distances?booleanComputes distances between clusters even if distance_threshold is not used. This can be used to make dendrogram visualization, but introduces a computational and memory overhead.
opts.compute_full_tree?boolean | "auto"Stop early the construction of the tree at n_clusters. This is useful to decrease computation time if the number of clusters is not small compared to the number of samples. This option is useful only when specifying a connectivity matrix. Note also that when varying the number of clusters and using caching, it may be advantageous to compute the full tree. It must be true if distance_threshold is not undefined. By default compute_full_tree is “auto”, which is equivalent to true when distance_threshold is not undefined or that n_clusters is inferior to the maximum between 100 or 0.02 \* n_samples. Otherwise, “auto” is equivalent to false.
opts.connectivity?ArrayLikeConnectivity matrix. Defines for each sample the neighboring samples following a given structure of the data. This can be a connectivity matrix itself or a callable that transforms the data into a connectivity matrix, such as derived from kneighbors_graph. Default is undefined, i.e, the hierarchical clustering algorithm is unstructured. For an example of connectivity matrix using kneighbors_graph, see Agglomerative clustering with and without structure.
opts.distance_threshold?numberThe linkage distance threshold at or above which clusters will not be merged. If not undefined, n_clusters must be undefined and compute_full_tree must be true.
opts.linkage?"ward" | "complete" | "average" | "single"Which linkage criterion to use. The linkage criterion determines which distance to use between sets of observation. The algorithm will merge the pairs of cluster that minimize this criterion.
opts.memory?stringUsed to cache the output of the computation of the tree. By default, no caching is done. If a string is given, it is the path to the caching directory.
opts.metric?stringMetric used to compute the linkage. Can be “euclidean”, “l1”, “l2”, “manhattan”, “cosine”, or “precomputed”. If linkage is “ward”, only “euclidean” is accepted. If “precomputed”, a distance matrix is needed as input for the fit method.
opts.n_clusters?numberThe number of clusters to find. It must be undefined if distance_threshold is not undefined.

Returns AgglomerativeClustering

Defined in generated/cluster/AgglomerativeClustering.ts:25

Properties

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

Accessors

children_

Get Signature

get children_(): Promise<ArrayLike[]>

The children of each non-leaf node. Values less than n_samples correspond to leaves of the tree which are the original samples. A node i greater than or equal to n_samples is a non-leaf node and has children children_\[i \- n_samples\]. Alternatively at the i-th iteration, children[i][0] and children[i][1] are merged to form node n_samples + i.

Returns Promise<ArrayLike[]>

Defined in generated/cluster/AgglomerativeClustering.ts:437


distances_

Get Signature

get distances_(): Promise<ArrayLike>

Distances between nodes in the corresponding place in children_. Only computed if distance_threshold is used or compute_distances is set to true.

Returns Promise<ArrayLike>

Defined in generated/cluster/AgglomerativeClustering.ts:464


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/AgglomerativeClustering.ts:410


labels_

Get Signature

get labels_(): Promise<ArrayLike>

Cluster labels for each point.

Returns Promise<ArrayLike>

Defined in generated/cluster/AgglomerativeClustering.ts:302


n_clusters_

Get Signature

get n_clusters_(): Promise<number>

The number of clusters found by the algorithm. If distance_threshold=None, it will be equal to the given n_clusters.

Returns Promise<number>

Defined in generated/cluster/AgglomerativeClustering.ts:275


n_connected_components_

Get Signature

get n_connected_components_(): Promise<number>

The estimated number of connected components in the graph.

Returns Promise<number>

Defined in generated/cluster/AgglomerativeClustering.ts:356


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/cluster/AgglomerativeClustering.ts:383


n_leaves_

Get Signature

get n_leaves_(): Promise<number>

Number of leaves in the hierarchical tree.

Returns Promise<number>

Defined in generated/cluster/AgglomerativeClustering.ts:329


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/cluster/AgglomerativeClustering.ts:82

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/AgglomerativeClustering.ts:138


fit()

fit(opts): Promise<any>

Fit the hierarchical clustering from features, or distance matrix.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLikeTraining instances to cluster, or distances between instances if metric='precomputed'.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<any>

Defined in generated/cluster/AgglomerativeClustering.ts:155


fit_predict()

fit_predict(opts): Promise<ArrayLike>

Fit and return the result of each sample’s clustering assignment.

In addition to fitting, this method also return the result of the clustering assignment for each sample in the training set.

Parameters

ParameterTypeDescription
optsobject-
opts.X?ArrayLike[]Training instances to cluster, or distances between instances if affinity='precomputed'.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<ArrayLike>

Defined in generated/cluster/AgglomerativeClustering.ts:196


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/AgglomerativeClustering.ts:239


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/AgglomerativeClustering.ts:95