SOMPlots — Visualization

SOMPlots extends either SOM or SOMGpu (whichever is available) with a full suite of visualization methods. It is the recommended entry point for most users.

from NNSOM.plots import SOMPlots

som = SOMPlots((8, 8))
som.init_w(data)
som.train(data, init_neighborhood=3, epochs=200, steps=100)

fig, ax, patches = som.plot('neuron_dist')
class NNSOM.plots.SOMPlots(dimensions)[source]

Bases: SOM

A subclass of either SOM or SOMGpu (based on the availability of CuPy), designed to provide visualization and interactive plotting capabilities for Self-Organizing Maps (SOMs). This class is intended to enrich the analysis of SOMs by offering a variety of advanced visualization techniques to explore the trained SOM topology, distribution of data points, and various statistics derived from the SOM’s learning process.

dimensions

A Gird of the SOM topology.

The class includes methods for plotting the topology of the SOM, generating hit histograms,
displaying cluster information, and more. These methods support interactive features through
mouse clicks, allowing users to engage with the visualizations dynamically. Each method
can also handle additional parameters for customization and handles various plotting styles
like hexagonal units, numbered neurons, color gradients, and complex cluster histograms.
The class also provides a generic plot method to handle different types of SOM visualizations
and an event handling method to manage user interactions during the plotting sessions.

This class supports interactivity and offers multiple visualization methods to deeply understand and analyze the behaviors and results of SOMs. It’s especially useful for gaining insights into the topology, data distribution, and classification performance of SOMs.

Constructor

SOMPlots.__init__

Initializes the SOMPlots class with specified dimensions for the SOM grid.

Topology plots

SOMPlots.plt_top

Plots the topology of the SOM using hexagonal units.

SOMPlots.plt_top_num

Plots the topology of the SOM with each neuron numbered.

Hit and distance maps

SOMPlots.hit_hist

Generates a hit histogram for the SOM, which displays the frequency of data points assigned to each neuron.

SOMPlots.neuron_dist_plot

Generates a neuron distance plot that visualizes the distances between neighboring neurons in the SOM grid.

SOMPlots.gray_hist

Generates a grayscale histogram for the SOM, where the shade of each hexagon represents the corresponding value from the provided percentage array.

Cluster and class plots

SOMPlots.cmplx_hit_hist

Generates a complex hit histogram for the SOM, incorporating information about cluster quality, misclassifications, and false positives/negatives.

SOMPlots.custom_cmplx_hit_hist

Generates a custom complex hit histogram for the SOM, allowing for flexible customization of the hexagon face colors, edge colors, and edge widths.

SOMPlots.simple_grid

Generates a simple grid plot that visualizes the SOM neurons as hexagons with varying sizes and colors.

SOMPlots.plt_nc

Generates a Neighborhood Connection Map for the SOM, displaying the connections between neighboring neurons.

Color-coded and component maps

SOMPlots.color_hist

Generates a colored histogram for the SOM, where the color of each hexagon represents the corresponding value from the provided average array.

SOMPlots.plt_stem

Generates a stem plot visualization for the SOM, displaying the input data and neuron responses.

SOMPlots.plt_pie

Generates a pie chart visualization for the SOM, displaying the composition of each neuron's data or cluster.

SOMPlots.plt_wgts

Generates a line plot visualization for the SOM weights, displaying the weight vectors for each neuron.

SOMPlots.plt_histogram

Generates a histogram visualization for the SOM, displaying the data distribution within each neuron's cluster.

SOMPlots.plt_boxplot

Generates a boxplot visualization for the SOM, displaying the statistical summary of the data distribution within each neuron's cluster.

SOMPlots.plt_violin_plot

Generates a violin plot visualization for the SOM, displaying the distribution of data within each neuron's cluster.

SOMPlots.plt_scatter

Generates a scatter plot visualization for the SOM, displaying the data points assigned to each neuron and an optional regression line.

SOMPlots.component_positions

Visualizes the positions of the components in a Self-Organizing Map (SOM) along with the input vectors.

SOMPlots.component_planes

Visualizes the weight distribution across different features in a Self-Organizing Map (SOM) using a series of 2D plots.

SOMPlots.weight_as_image

Visualizes the weights of a Self-Organizing Map (SOM) as images within a hexagonal grid layout.

Interactive plot

SOMPlots.plot

Generic Plot Function.