New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

kohonen

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kohonen

A basic implementation of a Kohonen map in JavaScript

latest
Source
npmnpm
Version
0.7.0
Version published
Weekly downloads
15
275%
Maintainers
1
Weekly downloads
 
Created
Source

kohonen Build Status

A basic implementation of a Kohonen map in JavaScript

`We are still on an early stage of dev. Do not use this package until v1.0.0 has been released.

Usage

Import lib

npm i kohonen --save

Then, in your JS script :

import Kohonen, {hexagonHelper} from 'kohonen';

API

Kohonen

The Kohonen class is the main class.

Constructor
param namedefinitiontypemandatorydefault
neuronsgrid of neuronsArrayyes
datadatasetArray of Arrayyes
maxStepstep max to clampNumberno10000
maxLearningCoefNumberno1
minLearningCoefNumberno.3
maxNeighborhoodNumberno1
minNeighborhoodNumberno.3

// instanciate your Kohonen map
const k = new Kohonen({data, neurons});

// you can use the grid helper to generate a grid with 10x10 hexagons
const k = new Kohonen({data, neurons: hexagonHelper.generateGrid(10,10)});

neurons parameter should be a flat array of { pos: [x,y] }. pos array being the coordinate on the grid.

data parameter is an array of the vectors you want to display. There is no need to standardize your data, that will be done internally by scaling each feature to the [0,1] range.

Basically the constructor do :

  • standardize the given data set
  • initialize random weights for neurons using PCA's largests eigenvectors
training method
param namedefinitiontypemandatorydefault
logfunc called after each step of learning processFunctionno()=>{}
k.training();

training method iterates on random vectors picked on normalized data. If a log function is provided as a parameter, it will receive instance neurons and step as params.

mapping method

mapping method returns grid position for each data provided on the constructor.

const myPositions = k.mapping();
umatrix method

umatrix method returns the U-Matrix of the grid (currently only with standardized vectors).

const umatrix = k.umatrix();

Example

We've developed a full example on a dedicated repository

capture

(Re)sources

FAQs

Package last updated on 01 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts