Simple implementation of Self Organizing Maps (SOMs) with rectangular and hexagonal grid topologies

Overview

py-self-organizing-map

Simple implementation of Self Organizing Maps (SOMs) with rectangular and hexagonal grid topologies. A SOM is a simple unsupervised method to learn a mapping from a source space to a typically two-dimensional target space. It starts with an initial neighborhood graph (either with a rectangular or hexagonal topology) where each node is associated with a weight vector (same number of components as source space). Then, iteratively, a "random" sample from the dataset is chosen and the node with the best matching weight w.r.t. some distance metric is determined. The weights of this best matching node and its neighbors are then slightly dragged towards the sample vector. This procedure is repeated for a certain number of iterations such that over time more and more nodes are positioned in high-density regions of the dataset while the neighborhood relation leads to a relatively smooth mapping.

There are quite a few hyperparameters such as height and width of the discrete grid, the initialization, the distance_metric, the topology, the number ofepochs or the initial_radius. All of these have a large impact on the resulting map, so please feel free to play around with it.

from som import SelfOrganizingMap

# create a random set of RGB color vectors
N = 1000
X = np.random.randint(0, 255, (N, 3))

# create the SOM and fit it to the color vectors
s = SelfOrganizingMap(height=32, width=32, topology='rectangular', initialization='random_uniform', distance_metric='l2')
s.fit(X, epochs=10, lr_decay=0.1, radius_decay=0.1, initial_radius=4)

# plot the learned map
f = plt.figure()
ax1 = f.add_subplot(121)
ax2 = f.add_subplot(122)
s.plot_som(ax1)
s.plot_node_difference_map(ax2)
plt.show()

You might also like...
A package for plotting maps in R with ggplot2
A package for plotting maps in R with ggplot2

Attention! Google has recently changed its API requirements, and ggmap users are now required to register with Google. From a user’s perspective, ther

Visualize data of Vietnam's regions with interactive maps.
Visualize data of Vietnam's regions with interactive maps.

Plotting Vietnam Development Map This is my personal project that I use plotly to analyse and visualize data of Vietnam's regions with interactive map

By default, networkx has problems with drawing self-loops in graphs.
By default, networkx has problems with drawing self-loops in graphs.

By default, networkx has problems with drawing self-loops in graphs. It makes it hard to draw a graph with self-loops or to make a nicely looking chord diagram. This repository provides some code to draw self-loops nicely

Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.
Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax.

PyDexter Simple plotting for Python. Python wrapper for D3xter - render charts in the browser with simple Python syntax. Setup $ pip install PyDexter

Simple python implementation with matplotlib to manually fit MIST isochrones to Gaia DR2 color-magnitude diagrams

Simple python implementation with matplotlib to manually fit MIST isochrones to Gaia DR2 color-magnitude diagrams

eoplatform is a Python package that aims to simplify Remote Sensing Earth Observation by providing actionable information on a wide swath of RS platforms and provide a simple API for downloading and visualizing RS imagery
eoplatform is a Python package that aims to simplify Remote Sensing Earth Observation by providing actionable information on a wide swath of RS platforms and provide a simple API for downloading and visualizing RS imagery

An Earth Observation Platform Earth Observation made easy. Report Bug | Request Feature About eoplatform is a Python package that aims to simplify Rem

Simple and lightweight Spotify Overlay written in Python.
Simple and lightweight Spotify Overlay written in Python.

Simple Spotify Overlay This is a simple yet powerful Spotify Overlay. About I have been looking for something like this ever since I got Spotify. I th

This is a Cross-Platform Plot Manager for Chia Plotting that is simple, easy-to-use, and reliable.
This is a Cross-Platform Plot Manager for Chia Plotting that is simple, easy-to-use, and reliable.

Swar's Chia Plot Manager A plot manager for Chia plotting: https://www.chia.net/ Development Version: v0.0.1 This is a cross-platform Chia Plot Manage

Yata is a fast, simple and easy Data Visulaization tool, running on python dash
Yata is a fast, simple and easy Data Visulaization tool, running on python dash

Yata is a fast, simple and easy Data Visulaization tool, running on python dash. The main goal of Yata is to provide a easy way for persons with little programming knowledge to visualize their data easily.

Owner
Jonas Grebe
Computer science master student @ TU Darmstadt
Jonas Grebe
Massively parallel self-organizing maps: accelerate training on multicore CPUs, GPUs, and clusters

Somoclu Somoclu is a massively parallel implementation of self-organizing maps. It exploits multicore CPUs, it is able to rely on MPI for distributing

Peter Wittek 239 Nov 10, 2022
Color maps for POV-Ray v3.7 from the Plasma, Inferno, Magma and Viridis color maps in Python's Matplotlib

POV-Ray-color-maps Color maps for POV-Ray v3.7 from the Plasma, Inferno, Magma and Viridis color maps in Python's Matplotlib. The include file Color_M

Tor Olav Kristensen 1 Apr 5, 2022
A Python Library for Self Organizing Map (SOM)

SOMPY A Python Library for Self Organizing Map (SOM) As much as possible, the structure of SOM is similar to somtoolbox in Matlab. It has the followin

Vahid Moosavi 497 Dec 29, 2022
Tools for writing, submitting, debugging, and monitoring Storm topologies in pure Python

Petrel Tools for writing, submitting, debugging, and monitoring Storm topologies in pure Python. NOTE: The base Storm package provides storm.py, which

AirSage 247 Dec 18, 2021
A central task in drug discovery is searching, screening, and organizing large chemical databases

A central task in drug discovery is searching, screening, and organizing large chemical databases. Here, we implement clustering on molecular similarity. We support multiple methods to provide a interactive exploration of chemical space.

NVIDIA Corporation 124 Jan 7, 2023
Tweets your monthly GitHub Contributions as Wordle grid

Tweets your monthly GitHub Contributions as Wordle grid

Venu Vardhan Reddy Tekula 5 Feb 16, 2022
UNMAINTAINED! Renders beautiful SVG maps in Python.

Kartograph is not maintained anymore As you probably already guessed from the commit history in this repo, Kartograph.py is not maintained, which mean

null 1k Dec 9, 2022
Python Data. Leaflet.js Maps.

folium Python Data, Leaflet.js Maps folium builds on the data wrangling strengths of the Python ecosystem and the mapping strengths of the Leaflet.js

null 6k Jan 2, 2023
Easily convert matplotlib plots from Python into interactive Leaflet web maps.

mplleaflet mplleaflet is a Python library that converts a matplotlib plot into a webpage containing a pannable, zoomable Leaflet map. It can also embe

Jacob Wasserman 502 Dec 28, 2022
🗾 Streamlit Component for rendering kepler.gl maps

streamlit-keplergl ?? Streamlit Component for rendering kepler.gl maps in a streamlit app. ?? Live Demo ?? Installation pip install streamlit-keplergl

Christoph Rieke 39 Dec 14, 2022