An implementation of self-organizing maps (SOMs) with a number of distinguishing features:
Support for both Python and R.
Automatic centroid detection and visualization using starbursts.
Two models of the data: (a) a self organizing map model, (b) a centroid based clustering model.
A number of easily accessible quality metrics.
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)
The documentation for the sklearn compatible Python API.
The documentation for the Python API based on the R implementation.
To install popsom in Python head to the PyPi website and search for ‘popsom7’.
To install popsom in R head to the CRAN website and search for ‘popsom7’.