A Kohonen Network API for Node.js
The Self-Organizing Map (commonly also known as Kohonen network) defines an ordered mapping, a kind of projection from a set of given data items onto a regular, usually two-dimensional grid.
Installation
$ npm install node-som
Color Clustering Example
This example shows how the SOM can adaptively cluster a random RGB input space based on the network's training state.
$ npm install node-som$ cd node_modules/node-som/$ node examples/colors/colors-cluster.js$ open examples/colors/color.html
Usage
// Inject the modulevar som = ;// Create the instancevar somInstance =inputLength: 2maxClusters: 5loggingEnabled: truescale:min : 0max : 1000;/*** Train (all automatic). Optionally, you can include custom input vectors, but* it is recommended that developers allow the automated training (based on the* `scale` configuration) since this results in better networks*/somInstance;/*** Create input array.* All items features should be normalized to domain [0,1]*/var sample = 024 034;// Call classify to receive your classification group/neuronvar group = somInstance;// For the sake of intelligence, you can use the somInstance.statistics object to track known neuron usage## Options###Enables/Disables logging on the console###Max number of Classification groups to use This is an upper-bound and an optimized network usually contains less than this number###When the network was initially created###Represents the number of classifications run through the network Used as a metric of maturity###Component length of input vectors###Represents the number of random samples to self-train on Higher numbers cost more but can result in more granular groups###Tells the SOM how to train to insure high accuracy on the target domain ex min: -1000 max: 1000## API###trainAccepts an array of unscaled input vectors of ordinal length `inputLength` The implementation scales itself based on the `scale`.###serializeSerialize the network for future use.Reloading the network can be done by passing the serialized json into the constructor on instantiation.###scaleInputScales a vector of `inputLength` based on the SOM's `scale` boundaries.> Note: Scaling is done internally. No need to do this unless extending the network implementation.###descaleInputDescales a scalled vector of `inputLength` based on the SOM's `scale` boundaries.> Note: Descaling is done internally. No need to do this unless extending the network implementation.