popsom7

A Fast, User-friendly Implementation of Self-Organizing Maps

Overview

An implementation of self-organizing maps (SOMs) with a number of distinguishing features:

  1. Support for both Python and R.

  2. Easy to use interfaces for building and evaluating self-organizing maps:
    • An interface that works the same on both the R and the Python platforms
    • An interface that is sklearn compatible, allowing you to leverage the power and convenience of the sklearn framework in Python.
  3. Automatic centroid detection and visualization using starbursts.

  4. Two models of the data: (a) a self organizing map model, (b) a centroid based clustering model.

  5. A number of easily accessible quality metrics.

  6. An implementation of the training algorithm based on tensor algebra.

Example Code in both Python and R

Here is a simple example written in Python using the sklearn compatible API,

from popsom7.sklearnapi import SOM
import pandas as pd
from sklearn import datasets

iris = datasets.load_iris()
X = pd.DataFrame(iris.data, columns=iris.feature_names)
y = pd.DataFrame(iris.target_names[iris.target],columns=['species'])

# Create and fit the SOM model
som = SOM(xdim=20, ydim=15, train=100000, seed=42).fit(X, y)

# View a summary of the SOM
som.summary()

# Display the starburst (heat map) representation
som.starburst()

Here is the same example written in R,

# training data
data(iris)
df <- subset(iris,select=-Species)
labels <- subset(iris,select=Species)

# build a map
m <- map.build(df,labels,xdim=20,ydim=15,train=100000,seed=42)

# look at the characteristics of the maps
map.summary(m)

# plot the map
map.starburst(m)

Documentation

Worked Example Jupyter Notebooks

Installation

Github

Project Page