Code Monkey home page Code Monkey logo

g-neuralgas's Introduction

GrowingNeuralGas

About

A simple implementation of the Growing Neural Gas algorithm, based on:

A Growing Neural Gas Network Learns Topologies, B. Fritzke
Advances in Neural Information Processing Systems 7 (1995)`

Usage

Instantiate a GNG object with some data, then fit the neural network:

gng = GrowingNeuralGas(data)
gng.fit_network(e_b=0.1, e_n=0.006, a_max=10, l=200, a=0.5, d=0.995, passes=8, plot_evolution=True)

Example

This example shows (i) how to generate toy data (two interleaving half circles) using the scikit-learn lib and (ii) how to perform cluster analysis through the growing neural gas network:

from gng import GrowingNeuralGas
from sklearn import datasets
from sklearn.preprocessing import StandardScaler

print('Generating data...')
data = datasets.make_moons(n_samples=2000, noise=.05) 
data = StandardScaler().fit_transform(data[0])
print('Done.')
print('Fitting neural network...')
gng = GrowingNeuralGas(data)
gng.fit_network(e_b=0.1, e_n=0.006, a_max=10, l=200, a=0.5, d=0.995, passes=8, plot_evolution=True)
print('Found %d clusters.' % gng.number_of_clusters())
gng.plot_clusters(gng.cluster_data())

Running example.py will produce the following output:

Preparing data...
Done.
Fitting neural network...
   Pass #1
   Pass #2
   Pass #3
   Pass #4
   Pass #5
   Pass #6
   Pass #7
   Pass #8
Found 2 clusters.

Clusters

alt tag

Network properties

alt tag

Global error vs. number of passes

alt tag

Accumulated local error vs. total number of iterations

alt tag

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.