DBScan
Discover density-based clusters and noise with the DBScan JavaScript and TypeScript implementation in @kanaries/ml for browser and Node.js applications.
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.
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);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.
FAQ
What problem does DBScan solve in JavaScript machine learning projects?
DBScan helps teams implement production-ready ML workflows in browser and Node.js environments with a familiar scikit-learn-style API.
How does DBScan in JavaScript compare with scikit-learn in Python?
The @kanaries/ml version keeps the overall estimator workflow familiar for Python users while exposing JavaScript and TypeScript-friendly arrays, imports, and runtime behavior.
When should I choose DBScan instead of other Clusters algorithms?
Use DBScan when it best matches your data shape, labeling strategy, and runtime constraints. Benchmark against at least one alternative in the same module before finalizing defaults.
Can I run DBScan in both browser and Node.js with @kanaries/ml?
Yes. @kanaries/ml is designed for JavaScript and TypeScript runtimes across browser applications, server-side Node.js services, and edge-friendly workflows.
K-Means
Learn what K-Means clustering does, when to use it, and how to run K-Means in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.
HDBSCAN
Learn what HDBSCAN does, when to use it, and how to run HDBScan in JavaScript or TypeScript with @kanaries/ml for browser and Node.js applications.