Skip to main content

A Fast Self-Organizing Map Python Library Implemented in Numba

Project description

NumbaSOM

A Fast Self-Organizing Map Python Library Implemented in Numba.

If you need a fast and simple to use SOM library implemented as a 2D lattice or torus, check this out. It utilizes online rather than batch training.

Install

pip install numbasom

How to use

Train a SOM on 1000 random 3-dimensional vectors:

import numpy as np
from numbasom import SOM, u_matrix, plot_u_matrix

Load some data

data = np.random.randn(100,3)

Initialize the library

som = SOM(som_size=(20,20))

Train

lattice = som.train(data, num_iterations=1000)
Data scaling took: 0.338414 seconds.
SOM training took: 1.049132 seconds.

Display the value in the first row and first column of the lattice

lattice[1::6,1]
array([[0.72234145, 0.20699402, 0.48731189],
       [0.49514563, 0.18585944, 0.64291118],
       [0.39127316, 0.13052984, 0.4517087 ],
       [0.40195937, 0.42461381, 0.14699424]])

Make U-matrix

um = u_matrix(lattice)

Plot U-matrix

plot_u_matrix(um)

png

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

numbasom-0.0.1.tar.gz (12.3 kB view hashes)

Uploaded Source

Built Distribution

numbasom-0.0.1-py3-none-any.whl (10.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page