Skip to content

gvisco/ossom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ordinary Simple Self Organizing Map

A simple implementation of Self Organizing Map written in Python.

Basic usage

Get the dataset as a Scipy array NxM, where N is the number of samples and M is the number of features for each sample.

dataset = import_data(N, M)

Import Som class

from ossom.som import Som

Instantiate a new SOM, specifying the width and the height of the grid and the input size.

som = Som(W, H, M)

Newly created SOMs can be tweaked by setting parameters like learning rate, radius of the neighborhood function etc.

Train the model, iterating through the samples for E epochs:

for epoch in range(1, E):
    for x in dataset:
        som.train(x, epoch)

Use the trained map to classify data: given an input, find the unit of the map that better fits with it and get back its value -- or weight -- and its position within the grid.

row, column, weight, distance = som.classify(x)

Full sample code

A full running sample is available here. It does use a SOM to classify randomly generated data... not very useful indeed.

References

About

Ordinary Simple Self-Organizing Map

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages