Density Based Clustering for JavaScript
Package contains popular methods for cluster analysis in data mining:
- DBSCAN
- OPTICS
- K-MEANS
Overview
DBSCAN
Density-based spatial clustering of applications with noise (DBSCAN) is one of the most popular algorithm for clustering data.
http://en.wikipedia.org/wiki/DBSCAN
OPTICS
Ordering points to identify the clustering structure (OPTICS) is an algorithm for clustering data similar to DBSCAN. The main difference between OPTICS and DBSCAN is that it can handle data of varying densities.
http://en.wikipedia.org/wiki/OPTICS_algorithm
Important
Clustering returned by OPTICS is nearly indistinguishable from a clustering created by DBSCAN. To extract different density-based clustering as well as hierarchical structure you need to analyse reachability plot generated by OPTICS.
For more information visit http://en.wikipedia.org/wiki/OPTICS_algorithm#Extracting_the_clusters
K-MEANS
K-means clustering is one of the most popular method of vector quantization, originally from signal processing. Although this method is not density-based, it's included in the library for completeness.
http://en.wikipedia.org/wiki/K-means_clustering
Installation
Node:
npm install density-clustering
Browser:
bower install density-clustering# build npm installgulp
Examples
DBSCAN
var dataset = 110110 101010131313 5454555589895755; var clustering = ;var dbscan = ;// parameters: 5 - neighborhood radius, 2 - number of points in neighborhood to form a clustervar clusters = dbscan;console; /*RESULT:[ [0,1,2], [3,4,5], [6,7,9], [8]] NOISE: [ 8 ]*/
OPTICS
// REGULAR DENSITYvar dataset = 110110 101010111110 505051505051 100100; var clustering = ;var optics = ;// parameters: 2 - neighborhood radius, 2 - number of points in neighborhood to form a clustervar clusters = optics;var plot = optics;console; /*RESULT:[ [0,1,2], [3,4,5], [6,7,8], [9]]*/
// VARYING DENSITYvar dataset = 0060-10010-1 4545451452451453458455452453 50505650505250555051; var clustering = ;var optics = ;// parameters: 6 - neighborhood radius, 2 - number of points in neighborhood to form a clustervar clusters = optics;var plot = optics;console; /*RESULT:[ [0, 2, 3, 4], [1], [5, 6, 7, 9, 8], [10, 14, 12, 13], [11]]*/
K-MEANS
var dataset = 110110 101010131313 5454555589895755; var clustering = ;var kmeans = ;// parameters: 3 - number of clustersvar clusters = kmeans;console; /*RESULT:[ [0,1,2,3,4,5], [6,7,9], [8]]*/
Testing
Open folder and run:
mocha -R spec
License
Software is licensed under MIT license. For more information check LICENSE file.