Documentation
Classes
HDBSCAN

HDBSCAN

Cluster data using hierarchical density-based clustering.

HDBSCAN - Hierarchical Density-Based Spatial Clustering of Applications with Noise. Performs DBSCAN over varying epsilon values and integrates the result to find a clustering that gives the best stability over epsilon. This allows HDBSCAN to find clusters of varying densities (unlike DBSCAN), and be more robust to parameter selection. Read more in the User Guide.

For an example of how to use HDBSCAN, as well as a comparison to DBSCAN, please see the plotting demo.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new HDBSCAN(opts?: object): HDBSCAN;

Parameters

NameTypeDescription
opts?object-
opts.algorithm?"auto" | "brute" | "kdtree" | "balltree"Exactly which algorithm to use for computing core distances; By default this is set to "auto" which attempts to use a KDTree tree if possible, otherwise it uses a BallTree tree. Both "KDTree" and "BallTree" algorithms use the NearestNeighbors estimator. If the X passed during fit is sparse or metric is invalid for both KDTree and BallTree, then it resolves to use the "brute" algorithm. Default Value 'auto'
opts.allow_single_cluster?booleanBy default HDBSCAN* will not produce a single cluster, setting this to true will override this and allow single cluster results in the case that you feel this is a valid result for your dataset. Default Value false
opts.alpha?numberA distance scaling parameter as used in robust single linkage. See [3] for more information. Default Value 1
opts.cluster_selection_epsilon?numberA distance threshold. Clusters below this value will be merged. See [5] for more information. Default Value 0
opts.cluster_selection_method?"eom" | "leaf"The method used to select clusters from the condensed tree. The standard approach for HDBSCAN* is to use an Excess of Mass ("eom") algorithm to find the most persistent clusters. Alternatively you can instead select the clusters at the leaves of the tree – this provides the most fine grained and homogeneous clusters. Default Value 'eom'
opts.copy?booleanIf copy=True then any time an in-place modifications would be made that would overwrite data passed to fit, a copy will first be made, guaranteeing that the original data will be unchanged. Currently, it only applies when metric="precomputed", when passing a dense array or a CSR sparse matrix and when algorithm="brute". Default Value false
opts.leaf_size?numberLeaf size for trees responsible for fast nearest neighbour queries when a KDTree or a BallTree are used as core-distance algorithms. A large dataset size and small leaf\_size may induce excessive memory usage. If you are running out of memory consider increasing the leaf\_size parameter. Ignored for algorithm="brute". Default Value 40
opts.max_cluster_size?numberA limit to the size of clusters returned by the "eom" cluster selection algorithm. There is no limit when max\_cluster\_size=None. Has no effect if cluster\_selection\_method="leaf".
opts.metric?stringThe metric to use when calculating distance between instances in a feature array. Default Value 'euclidean'
opts.metric_params?anyArguments passed to the distance metric.
opts.min_cluster_size?numberThe minimum number of samples in a group for that group to be considered a cluster; groupings smaller than this size will be left as noise. Default Value 5
opts.min_samples?numberThe number of samples in a neighborhood for a point to be considered as a core point. This includes the point itself. When undefined, defaults to min\_cluster\_size.
opts.n_jobs?numberNumber of jobs to run in parallel to calculate distances. undefined means 1 unless in a joblib.parallel\_backend (opens in a new tab) context. \-1 means using all processors. See Glossary for more details.
opts.store_centers?stringWhich, if any, cluster centers to compute and store. The options are:

Returns

HDBSCAN

Defined in: generated/cluster/HDBSCAN.ts:25 (opens in a new tab)

Methods

dbscan_clustering()

Return clustering given by DBSCAN without border points.

Return clustering that would be equivalent to running DBSCAN* for a particular cut_distance (or epsilon) DBSCAN* can be thought of as DBSCAN without the border points. As such these results may differ slightly from cluster.DBSCAN due to the difference in implementation over the non-core points.

This can also be thought of as a flat clustering derived from constant height cut through the single linkage tree.

This represents the result of selecting a cut value for robust single linkage clustering. The min\_cluster\_size allows the flat clustering to declare noise points (and cluster smaller than min\_cluster\_size).

Signature

dbscan_clustering(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.cut_distance?numberThe mutual reachability distance cut value to use to generate a flat clustering.
opts.min_cluster_size?numberClusters smaller than this value with be called ‘noise’ and remain unclustered in the resulting flat clustering. Default Value 5

Returns

Promise<ArrayLike>

Defined in: generated/cluster/HDBSCAN.ts:213 (opens in a new tab)

dispose()

Disposes of the underlying Python resources.

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

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/cluster/HDBSCAN.ts:190 (opens in a new tab)

fit()

Find clusters based on hierarchical density-based clustering.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]A feature array, or array of distances between samples if metric='precomputed'.
opts.y?anyIgnored.

Returns

Promise<any>

Defined in: generated/cluster/HDBSCAN.ts:253 (opens in a new tab)

fit_predict()

Cluster X and return the associated cluster labels.

Signature

fit_predict(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]A feature array, or array of distances between samples if metric='precomputed'.
opts.y?anyIgnored.

Returns

Promise<ArrayLike>

Defined in: generated/cluster/HDBSCAN.ts:291 (opens in a new tab)

get_metadata_routing()

Get metadata routing of this object.

Please check User Guide on how the routing mechanism works.

Signature

get_metadata_routing(opts: object): Promise<any>;

Parameters

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

Returns

Promise<any>

Defined in: generated/cluster/HDBSCAN.ts:331 (opens in a new tab)

init()

Initializes the underlying Python resources.

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

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/cluster/HDBSCAN.ts:133 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/cluster/HDBSCAN.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/cluster/HDBSCAN.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/cluster/HDBSCAN.ts:21 (opens in a new tab)

id

string

Defined in: generated/cluster/HDBSCAN.ts:18 (opens in a new tab)

opts

any

Defined in: generated/cluster/HDBSCAN.ts:19 (opens in a new tab)

Accessors

centroids_

A collection containing the centroid of each cluster calculated under the standard euclidean metric. The centroids may fall “outside” their respective clusters if the clusters themselves are non-convex.

Note that n\_clusters only counts non-outlier clusters. That is to say, the \-1, \-2, \-3 labels for the outlier clusters are excluded.

Signature

centroids_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cluster/HDBSCAN.ts:464 (opens in a new tab)

feature_names_in_

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

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cluster/HDBSCAN.ts:437 (opens in a new tab)

labels_

Cluster labels for each point in the dataset given to fit. Outliers are labeled as follows:

Signature

labels_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cluster/HDBSCAN.ts:364 (opens in a new tab)

medoids_

A collection containing the medoid of each cluster calculated under the whichever metric was passed to the metric parameter. The medoids are points in the original cluster which minimize the average distance to all other points in that cluster under the chosen metric. These can be thought of as the result of projecting the metric-based centroid back onto the cluster.

Note that n\_clusters only counts non-outlier clusters. That is to say, the \-1, \-2, \-3 labels for the outlier clusters are excluded.

Signature

medoids_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/cluster/HDBSCAN.ts:489 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/cluster/HDBSCAN.ts:412 (opens in a new tab)

probabilities_

The strength with which each sample is a member of its assigned cluster.

Signature

probabilities_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/cluster/HDBSCAN.ts:387 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/cluster/HDBSCAN.ts:120 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/cluster/HDBSCAN.ts:124 (opens in a new tab)