CHINESE-WHISPERS
An Efficient Graph Clustering Algorithm for JavaScript/Node.js
Picture credit: http://www.wikihow.com/Play-Chinese-Whispers
ALGORITHM
Chinese Whispers - an Efficient Graph Clustering Algorithm and its Application to Natural Language Processing Problems
Author: Chris Biemann, University of Leipzig, NLP-Dept. Leipzig, Germany
INSTALL
npm install chinese-whispers
EXAMPLE
Talk is cheap, show me the code!
for in clusterIndicesList // Cluster[0]: 0,1,2// Cluster[1]: 10,11,12// Cluster[2]: 20,21,22
Source code can be found at: https://github.com/huan/chinese-whispers/blob/master/examples/demo.ts
API
The ChineseWhispers
class is all you need to run the Chinese Whispers Algorithm.
constructor(options: ChineseWhisperOptions)
1.
options
weightFunc
: a function that takes two data item, calculate the weight between them and return the value.epochs
: how many epoches to run the algorithm, default 15.threshold
: minimum weight required for a edge. default 0.
// calculate the distance between vectors
cluster(dataList): number[][]
2. Process dataList
which is an array of data, returns the cluster results as an array, each array item is a cluster, and each cluster is an array which includes the indices of dataList that belongs to this cluster.
for in clusterIndicesList
INSPIRATION
The code is heavily inspired by the following implementation:
- facenet chinese whispers(face cluster) in Python - zhly0
- Chinese Whispers Graph Clustering in Python - Alex Loveless
- A Python implementation of Chris Biemann's algorithm for graph clustering
- Implementation of the Chinese Whispers graph clustering algorithm in Java
- Chinese Whispers Graph Clustering Algorithm in Javascript
SEE ALSO
- The meaning and origin of the expression: Chinese whispers
- TensorFlow backed FaceNet implementation for Node.js - Face verification, face recognition and face clustering.
CHANGELOG
v0.2 master
- Upgrade TypeScript to 3.0
- DevOps to npm@next
v0.1 Sep 2017
ChineseWhispers
classcluster()
class method- Unit test cases
- Travis CI & CD(publish to NPM automatically)
AUTHOR
Huan LI <zixia@zixia.net> (http://linkedin.com/in/zixia)
COPYRIGHT & LICENSE
- Code & Docs © 2017-2019 Huan LI <zixia@zixia.net>
- Code released under the Apache-2.0 License
- Docs released under Creative Commons