JSPM

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

A TypeScript implementation of AGNES an 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

Build Status npm version

A TypeScript implementation of AGNES an agglomerative 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:

    import { CentroidLinkage, Dendrogram, HierarchicalClustering } from 'dbvis-hc';

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

Linkage Strategies

  • Single-Linkage
  • Complete-Linkage
  • Average-Linkage
  • Average-Group-Linkage
  • Centroid-Linkage