Mike Mike - 1 month ago 10
Python Question

Hexagonal Self-Organizing map in Python

I am looking for hexagonal self-organizing map on Python.


hexagonal tiling


  1. ready module. If one exists.

  2. way to plot hexagonal cell

  3. algorithms to work with hexagonal cells as array or smth else



About:
A self-organizing map (SOM) or self-organizing feature map (SOFM) is a type of artificial neural network that is trained using unsupervised learning to produce a low-dimensional (typically two-dimensional)

Answer

I don't have an answer for point 1, but some hints for point 2 and 3. In your context, you're not modelling a physical 2D space but a conceptual space with tiles that have 6 neighbors. This can be modelled with square tiles arranged in columns with the odd colums shifted vertically by half the size of a square. I'll try an ASCII diagram:

 ___     ___     ___     
|   |___|   |___|   |___
|___|   |___|   |___|   |
|   |___|   |___|   |___|
|___|   |___|   |___|   |
|   |___|   |___|   |___|
|___|   |___|   |___|   |
    |___|   |___|   |___|

You can see easily that each square has 6 neighbors (except the ones on the edges of course). This gets easily modeled as a 2D array of squares, and the rules to compute the coordinates of the square at at position (i, j), i being the row and j the column are quite simple:

if j is even:

(i+1, j), (i-1, j), (i, j-1), (i, j+1), (i-1, j-1), (i+1, j-1)

if j is odd:

(i+1, j), (i-1, j), (i, j-1), (i, j+1), (i+1, j-1), (i+1, j+1)

(the 4 first terms are identical)