Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ml-hclust

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-hclust

Hierarchical clustering algorithms in Javascript

  • 0.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
898
decreased by-49.38%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 25 Jun 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc