dbvis-hc
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
:
Usage
This implementation can be used to cluster generic objects, given a useful definition of distance and in case of the Centroid-Linkage, additionally a definition for aggregation.
Example:
; const data = 10 09 10 11 11 ; // Distance function required by all linkage strategies const distFunc = a: number b: number: Math; // Aggregation function only needed by the centroid linkage strategy const aggrFunc = v: number: v / vlength; const hc = <number>data distFunc aggrFunc; const rootCluster = hc; // Split cluster according to the dendrogram and a cut-off value const dendrogram = <number>rootCluster 93; const clustersAsRefs = dendrogram; // clustersAsRefs: [ [1.1, 0.9, 1.0], [10, 11] ] const clustersAsIds = dendrogram; // clustersAsIds: [ [ 4, 1, 2 ], [ 3, 0 ] ]
Linkage Strategies
This package provides common linkage strategies:
- Single-Linkage
- Complete-Linkage
- Average-Linkage
- Average-Group-Linkage
- Centroid-Linkage
You can provide your own linkage method by subtyping the AbstractLinkage
class.