Class: DBSCAN

Perform DBSCAN clustering from vector array or distance matrix.

DBSCAN - Density-Based Spatial Clustering of Applications with Noise. Finds core samples of high density and expands clusters from them. Good for data which contains clusters of similar density.

This implementation has a worst case memory complexity of \(O({n}^2)\), which can occur when the eps param is large and min_samples is low, while the original DBSCAN only uses linear memory. For further details, see the Notes below.

Read more in the User Guide.

Python Reference

Constructors

new DBSCAN()

new DBSCAN(opts?): DBSCAN

Parameters

ParameterTypeDescription
opts?object-
opts.algorithm?"auto" | "ball_tree" | "kd_tree" | "brute"The algorithm to be used by the NearestNeighbors module to compute pointwise distances and find nearest neighbors. See NearestNeighbors module documentation for details.
opts.eps?numberThe maximum distance between two samples for one to be considered as in the neighborhood of the other. This is not a maximum bound on the distances of points within a cluster. This is the most important DBSCAN parameter to choose appropriately for your data set and distance function.
opts.leaf_size?numberLeaf size passed to BallTree or cKDTree. This can affect the speed of the construction and query, as well as the memory required to store the tree. The optimal value depends on the nature of the problem.
opts.metric?anyThe metric to use when calculating distance between instances in a feature array. If metric is a string or callable, it must be one of the options allowed by sklearn.metrics.pairwise_distances for its metric parameter. If metric is “precomputed”, X is assumed to be a distance matrix and must be square. X may be a sparse graph, in which case only “nonzero” elements may be considered neighbors for DBSCAN.
opts.metric_params?anyAdditional keyword arguments for the metric function.
opts.min_samples?numberThe number of samples (or total weight) in a neighborhood for a point to be considered as a core point. This includes the point itself. If min_samples is set to a higher value, DBSCAN will find denser clusters, whereas if it is set to a lower value, the found clusters will be more sparse.
opts.n_jobs?numberThe number of parallel jobs to run. undefined means 1 unless in a joblib.parallel_backend context. \-1 means using all processors. See Glossary for more details.
opts.p?numberThe power of the Minkowski metric to be used to calculate distance between points. If undefined, then p=2 (equivalent to the Euclidean distance).

Returns DBSCAN

Defined in generated/cluster/DBSCAN.ts:27

Properties

PropertyTypeDefault valueDefined in
_isDisposedbooleanfalsegenerated/cluster/DBSCAN.ts:25
_isInitializedbooleanfalsegenerated/cluster/DBSCAN.ts:24
_pyPythonBridgeundefinedgenerated/cluster/DBSCAN.ts:23
idstringundefinedgenerated/cluster/DBSCAN.ts:20
optsanyundefinedgenerated/cluster/DBSCAN.ts:21

Accessors

components_

Get Signature

get components_(): Promise<ArrayLike[]>

Copy of each core sample found by training.

Returns Promise<ArrayLike[]>

Defined in generated/cluster/DBSCAN.ts:329


core_sample_indices_

Get Signature

get core_sample_indices_(): Promise<ArrayLike>

Indices of core samples.

Returns Promise<ArrayLike>

Defined in generated/cluster/DBSCAN.ts:304


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/DBSCAN.ts:397


labels_

Get Signature

get labels_(): Promise<ArrayLike>

Cluster labels for each point in the dataset given to fit(). Noisy samples are given the label -1.

Returns Promise<ArrayLike>

Defined in generated/cluster/DBSCAN.ts:352


n_features_in_

Get Signature

get n_features_in_(): Promise<number>

Number of features seen during fit.

Returns Promise<number>

Defined in generated/cluster/DBSCAN.ts:374


py

Get Signature

get py(): PythonBridge

Returns PythonBridge

Set Signature

set py(pythonBridge): void

Parameters

ParameterType
pythonBridgePythonBridge

Returns void

Defined in generated/cluster/DBSCAN.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/DBSCAN.ts:133


fit()

fit(opts): Promise<any>

Perform DBSCAN clustering from features, or distance matrix.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeWeight of each sample, such that a sample with a weight of at least min_samples is by itself a core sample; a sample with a negative weight may inhibit its eps-neighbor from being core. Note that weights are absolute, and default to 1.
opts.X?anyTraining instances to cluster, or distances between instances if metric='precomputed'. If a sparse matrix is provided, it will be converted into a sparse csr_matrix.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<any>

Defined in generated/cluster/DBSCAN.ts:150


fit_predict()

fit_predict(opts): Promise<ArrayLike>

Compute clusters from a data or distance matrix and predict labels.

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?ArrayLikeWeight of each sample, such that a sample with a weight of at least min_samples is by itself a core sample; a sample with a negative weight may inhibit its eps-neighbor from being core. Note that weights are absolute, and default to 1.
opts.X?anyTraining instances to cluster, or distances between instances if metric='precomputed'. If a sparse matrix is provided, it will be converted into a sparse csr_matrix.
opts.y?anyNot used, present here for API consistency by convention.

Returns Promise<ArrayLike>

Defined in generated/cluster/DBSCAN.ts:192


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/DBSCAN.ts:236


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


set_fit_request()

set_fit_request(opts): Promise<any>

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

Parameters

ParameterTypeDescription
optsobject-
opts.sample_weight?string | booleanMetadata routing for sample_weight parameter in fit.

Returns Promise<any>

Defined in generated/cluster/DBSCAN.ts:272