NNSOM.plots.SOMPlots.weight_as_image

SOMPlots.weight_as_image(rows=None, mouse_click=False, connect_pick_event=True, **kwargs)[source]

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

This method maps the weight vectors of each neuron onto a hexagonal cell and optionally enables interaction with each hexagon. The hexagons represent the neurons, and the colors within each hexagon represent the neuron’s weight vector reshaped into either a specified or automatically determined matrix form. This visualization is useful for analyzing the learned patterns and feature representations within the SOM.

Parameters:
  • rows (int, optional) – The number of rows to reshape each neuron’s weight vector into. If None, the weight vector is reshaped into a square matrix by default. If specified, the weight vector is reshaped into a matrix with the given number of rows, and the number of columns is determined automatically.

  • mouse_click (bool, optional) – If True, enables the plot to respond to mouse clicks, allowing for interactive functionality such as querying or modifying neuron data, by default False.

  • connect_pick_event (bool, optional) – If True, connects a pick event that triggers when a neuron is clicked, by default True.

  • **kwargs (dict) – Arbitrary keyword arguments that can be passed to the event handler onpick when an interactive element is clicked. Common parameters could include data specific to the plot or visualization settings.

Returns:

  • fig (matplotlib.figure.Figure) – The Figure object containing the plot.

  • ax (matplotlib.axes.Axes) – The Axes object containing the plot elements.

  • patches (list) – A list of matplotlib.patches.Patch objects, each representing a hexagon in the plot.