JSPM

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

A TypeScript implementation AGNES a agglomerative hierarchical clustering algorithm

Package Exports

  • dbvis-hc

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 (dbvis-hc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

dbvis-hc

A TypeScript implementation of a hierarchical clustering algorithm.

Install

Install with npm:

npm install --save dbvis-hc

This package requires module resolution by Node in tsconfig.json:

"compilerOptions": {
    "moduleResolution": "node"
}

Usage

Example:

    const data = [ 10, 0.9, 1.0, 11, 1.1 ];
    // Distance function required by all linkage strategies 
    const distFunc = (a: number, b: number) => Math.abs(a - b);
    // Aggregation function only needed by the centroid linkage strategy
    const aggrFunc = (v: number[]) => v.reduce((acc, curr) => acc + curr, 0) / v.length;
    const hc = new HierarchicalClustering(data, new CentroidLinkage(distFunc, aggrFunc));
    const dendrogram = new Dendrogram<number>(hc.cluster(), 9.3);
    const clusters = dendrogram.extractClusters();
    // Output: [ [ 4, 1, 2 ], [ 0, 3 ] ]