1.0.0 • Published 9 years ago

k.m.c v1.0.0

Weekly downloads
-
License
BSD-2-Clause
Repository
-
Last release
9 years ago

k-Means Clustering algorithm

This is an easy-to-use micro Node module that executes a kMC algorithm.

Current version: 1.0.0


Using

The module that you require in your code is the constructor of the kMC algorithm. This constructor takes one argument - the training data.

In order to launch the algorithm, use the launch function that takes 1 arguments - the k parameter - and returns an array with k cells(/clusters' centroids), each cell contains the coordinates of each point.

You can make multiple calculations by calling the "launch" function several times, with a different k.


Example

kMC = require("k.m.c");

var data = [ 831.5057004801929,20.94387263059616, 233.54505538009107,839.1174518037587, 216.1489767022431,84.10955290310085, 88.05029629729688,556.3338084612042, 955.1495676860213,290.3501314576715, 142.24169682711363,402.54066442139447, 958.026215666905,320.58246061205864, 742.53158015199,741.3020394742489, 538.1446806713939,683.4578807465732, 779.578068992123,913.3474384434521, 141.01124368607998,575.2535695210099, 388.96284252405167,155.98149900324643, 920.3229683917016,438.62350517883897, 754.2438684031367,109.24571333453059, 701.6594938468188,867.3292847815901, 492.28791892528534,807.7459882479161, 688.1855016108602,882.351509295404, 70.47889195382595,697.4109904840589, 645.9282780997455,979.2583852540702, 396.22214436531067,666.6961333248764, 124.61378099396825,727.8992859646678, 173.6428402364254,789.7877844516188, 7.922745775431395,998.4288401901722, 230.3757017944008,608.7657823227346, 526.3460397254676,874.9168538488448, 270.817409735173,962.9022600129247, 357.60940075851977,890.8500513061881, 252.55131744779646,697.131423978135, 640.9155752044171,776.4615404885262, 266.86861319467425,703.2744907774031, 656.8251149728894,612.5200381502509, 750.8503696881235,875.0766385346651, 689.9876575917006,697.8443607222289, 161.2866793293506,994.5784988813102 ];

var example = new kMC(data);

var results = example.launch(3);

console.log(results);