@kanaries/ml
API Reference/Clustering

DBScan

Discover density-based clusters and noise with the DBScan JavaScript and TypeScript implementation in @kanaries/ml for browser and Node.js applications.

View as Markdown

Algorithm overview

DBSCAN groups points that are densely connected and marks sparse points as noise. It is useful when cluster count is unknown and clusters may have irregular shapes.

JavaScript implementation

@kanaries/ml provides Clusters.DBScan for JavaScript and TypeScript workflows. It accepts an epsilon radius, a minimum sample count, and a distance metric name.

Interactive DBSCAN playground

Tune the neighborhood radius and minimum sample count below. The cluster map is fitted live with Clusters.DBScan; click the chart to test whether a new point connects dense regions or remains noise.

Live clustering · runs in your browser

Learn DBSCAN by changing it

Change the neighborhood definition and watch dense regions connect while sparse observations become noise. Click the chart to add a point and refit.

Clusters.DBScan
Fitting the interactive model…

Quick start example

import { Clusters } from '@kanaries/ml';

const X = [[0, 0], [0.1, 0], [5, 5], [5.1, 5], [20, 20]];

const dbscan = new Clusters.DBScan(0.3, 2, 'euclidean');
const labels = dbscan.fitPredict(X);
console.log(labels);

Detailed API reference

new Clusters.DBScan(
  eps?: number,
  minSamples?: number,
  distanceType?: Distance.IDistanceType,
)

Methods:

  • fitPredict(samplesX: number[][]): number[]

Labels are numeric cluster ids starting at 0. Noise points are labeled -1.