GithubHelp home page GithubHelp logo

selforganizingmap's Introduction

SelfOrganizingMap

Implementation of Kohonen Self-organizing map using 2D training data in C++

alt text

Sample Code

Create a 2D double vector containing the network training data

vector<vector<double>> data = {
	{2,2}, {5,5}, {2,1},
	{1,2}, {6,5}, {5,6},
	{10,4}, {11,3}, {9,2},
	{6,7}
};

Create a 2D double vector containing the initial weights (initial map)

vector<vector<double>> weights = {
	{1, 3}, {6, 4}, {10, 1}
};

Create a new SOM object and set the network paramaters

SOM som = SOM::builder()
	.setEpochs(100) // number if iterations > 0
	.setLearningRate(1) // learning rate <= 1 and > 0
	.setNeighborhoodSize(0) // neighborhood function size
	.build();

Train the network using the created training data and the initial weights (initial map)

som.trainData(data, weights);

Call getWeights() to return the adjusted weights after the network training is completed

vector<vector<double>> adjusted = som.getWeights();

To get a point’s cluster, call getCluster() which will return the cluster’s index in the adjusted weights vector

int clusterIndex = som.getCluster(data[i]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.