DBSCAN#

Density-based spatial clustering of applications with noise (DBSCAN) is a data clustering algorithm proposed in [Ester96]. It is a density-based clustering non-parametric algorithm: given a set of observations in some space, it groups together observations that are closely packed together (observations with many nearby neighbors), marking as outliers observations that lie alone in low-density regions (whose nearest neighbors are too far away).

Operation

Computational methods

Programming Interface

Compute

Default method

compute(…)

compute_input

compute_result

Mathematical formulation#

Computation#

Given the set \(X = \{x_1 = (x_{11}, \ldots, x_{1p}), \ldots, x_n = (x_{n1}, \ldots, x_{np})\}\) of \(n\) \(p\)-dimensional feature vectors (further referred as observations), a metric for pairwise distance computation, a positive floating-point number epsilon and a positive integer minObservations, the problem is to get clustering assignments for each input observation, based on the definitions below [Ester96]: two observations \(x\) and \(y\) are considered to be in the same cluster if there is a core observation \(z\), and \(x\) and \(y\) are both reachable from \(z\).

Each cluster gets a unique identifier, an integer number from \(0\) to \(\text{total number of clusters } – 1\). Each observation is assigned an identifier of the cluster it belongs to, or \(-1\) if the observation considered to be a noise observation.

Supported distance metrics#

The distance used to decide whether \(y\) lies in the epsilon-neighborhood of \(x\) is selected via the metric parameter. DBSCAN reuses the Minkowski distances family with configurable degree \(p > 0\): degree = 1 yields the Manhattan (\(L_1\)) distance, degree = 2 yields the Euclidean (\(L_2\), default) distance, and the limit \(p \to \infty\) corresponds to the Chebyshev distance (\(L_\infty\)). The Manhattan, Euclidean and Chebyshev distances are also exposed as their own metric values. In addition, DBSCAN supports the Cosine distance for angular data. All metrics are supported on CPU and GPU, in both memory modes.

epsilon is interpreted in the units of the selected metric, so it generally has to be re-tuned after changing the metric. degree must be positive and finite for every metric and is read only by the Minkowski metric. As in scikit-learn, an all-zero observation is at Cosine distance \(1\) from every other observation, while every observation, including an all-zero one, belongs to its own neighborhood.

Programming Interface#

Refer to API Reference: DBSCAN.

Distributed mode#

The algorithm supports distributed execution in SPMD mode (only on GPU).

Usage Example#

Compute#

void run_compute(const table& data,
                           const table& weights) {
   double epsilon = 1.0;
   std::int64_t max_observations = 5;
   const auto dbscan_desc = kmeans::descriptor<float>{epsilon, max_observations}
      .set_result_options(dal::dbscan::result_options::responses);

   const auto result = compute(dbscan_desc, data, weights);

   print_table("responses", result.get_responses());
}

Examples#