JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 10129
  • Score
    100M100P100Q133738F
  • License MIT

Hierarchical clustering algorithms in Javascript

Package Exports

  • ml-hclust

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ml-hclust) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hclust

NPM version build status David deps npm download

Hierarchical clustering algorithms in JavaScript

Installation

npm install ml-hclust

Methods

Generate a clustering hierarchy.

  • AGNES (AGglomerative NESting): Continuously merge nodes that have the least dissimilarity.
  • DIANA (Divisive ANAlysis): The process starts at the root with all the points as one cluster and recursively splits the higher level clusters to build the dendrogram.
  • BIRCH (Balanced Iterative Reducing and Clustering using Hierarchies): Incrementally construct a CF (Clustering Feature) tree, a hierarchical data structure for multiphase clustering
  • CURE (Clustering Using REpresentatives):
  • CHAMELEON

new Hclust([options])

Creates a new Hclust instance with the given parameters or the default ones.

Arguments

  • options - Object with options for the algorithm

Options

  • name: The name of the hierarchical cluster, it could be agnes(default), diana, birch, cure or chameleon.
  • sim: The kind of distance or similarity to use between vectors, the default is euclidean, but for a complete list see ml-distance.
  • kind: The kind of similarity to use between clusters, it could be single(default), complete, average, centroid or ward

Example

var HCL = require('ml-hclust');

// actually this are the default values
var options = {
    name: 'agnes',
    sim: 'euclidean',
    kind: 'single'
};

var agnes = new HCL(options);

cluster(data)

Creates the tree based in the data points.

Arguments

  • data: Array of points to be clustered.

Example

var data = [[2,6], [3,4], [3,8]];
var myHcl = new HCL();
myHcl.cluster(data);

getLevel(L)

Returns L level of the hierarchical clustering tree.

Arguments

  • L - Level of the hierarchical tree.

Example

// the clustering points
var agnesData = [[2,6], [3,4], [3,8], [4,5], [4,7], [6,2], [7,2], [7,4], [8,4], [8,5]];

// creates the hierarchical tree
var HC = new Hclust();
HC.cluster(agnesData);

// the array of clusters
var ansAgnes = HC.getLevel(3);
/*
[ [ [ 3, 4 ], [ 4, 5 ], [ 3, 8 ], [ 4, 7 ] ],
  [ [ 6, 2 ], [ 7, 2 ] ],
  [ [ 7, 4 ], [ 8, 4 ], [ 8, 5 ] ],
  [ [ 2, 6 ] ] ]
*/

export()

Exports the model to a JSON object that can be written to disk and reloaded

load(model)

Returns a new Hclust instance based on the model.

Arguments

  • model - JSON object generated with Hclust.export()

Test

$ npm install
$ npm test

Authors

License

MIT