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.
Constructors
new DBSCAN()
new DBSCAN(
opts
?):DBSCAN
Parameters
Parameter | Type | Description |
---|---|---|
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 ? | number | The 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 ? | number | Leaf 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 ? | any | The 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 ? | any | Additional keyword arguments for the metric function. |
opts.min_samples ? | number | The 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 ? | number | The 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 ? | number | The 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
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/cluster/DBSCAN.ts:25 |
_isInitialized | boolean | false | generated/cluster/DBSCAN.ts:24 |
_py | PythonBridge | undefined | generated/cluster/DBSCAN.ts:23 |
id | string | undefined | generated/cluster/DBSCAN.ts:20 |
opts | any | undefined | generated/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
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Weight 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 ? | any | Training 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 ? | any | Not 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Weight 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 ? | any | Training 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 ? | any | Not 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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A 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
Parameter | Type |
---|---|
py | PythonBridge |
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
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in fit . |
Returns Promise
<any
>
Defined in generated/cluster/DBSCAN.ts:272