class: Umatrix

public class: Umatrix
Author:
Project: Phase: 1.0; Status: Proposed; Version: 1.0; Complexity: 1
Dates: Created: 15.12.2005 0:07:00; Modified: 15.12.2005 0:07:01;
Flags: Active: false; IsRoot: false; IsLeaf: false;
Extension Points:
UUID: {1D8525C3-B96D-453b-9841-BF01F71BB2FA}
Class for drawing SOM. For visualization SOM is used Umatrix (unified distance matrix). Umatrix is two dimensional array of hexagon. U-matrix visualizes the distances between the neurons (red dots). The distance between the adjacent neurons is calculated and presented with different colorings between the adjacent nodes. A dark coloring between the neurons corresponds to the large distance and thus a gap between the codebook values in the input space. A light coloring between the neurons signifies that the codebook vectors are close to each other in the input space. Light areas can be thought as clusters and dark areas as cluster separators. Ever neuron in net has cluster ID. If neurons are from differen clusters, than between them is drawed line, that separate them.

 

Goto: Fields, Methods

See also: Hexagon, KohonenNetwork, SOMForm

Appears in: CD Umatrix

Connections
 
Umatrix Attributes
Attribute Details
private Hexagon
  matrix
private int
  mX
private int
  mY
private Point
  drawingPosition
private Size
  drawingSize
private bool
  isEmpty
private KohonenNetwork
  kn
private Color
  bottomColor
Initial: Color.White
private Color
  topColor
Initial: Color.Black
private Color
  clusterLineColor
Initial: Color.Blue
private Color
  neuronColor
Initial: Color.Red
private Color
  textColor
Initial: Color.Red
private Color
  clusterIDColor
Initial: Color.Blue
private bool
  drawText
Initial: false
private bool
  drawClusters
Initial: true
private bool
  drawClusterID
Initial: false
 
Umatrix Methods
Operation Details
public
Umatrix():
Notes: Constructor
public
Umatrix(
   KohonenNetwork SOM,
   Point DrawingPosition,
   Size DrawingSize):
Notes: Constructor
public
Umatrix(
   KohonenNetwork SOM):
Notes: Constructor
public
Umatrix(
   KohonenNetwork SOM,
   int top,
   int bottom,
   int left,
   int right):
Notes: Constructor
public
BottomColor():Color
<<property>>
Notes: Color for the nearest neurons
public
TopColor():Color
<<property>>
Notes: Color for the most distant neurons
public
DrawingPosition():Point
<<property>>
Notes: Position, where U-matrix will be painted
public
DrawingSize():Size
<<property>>
Notes: Size of rectangle, where will U-matrix painted
public
SOM():KohonenNetwork
<<property>>
Notes: Network for drawing
public
IsEmpty():bool
<<property>>
Notes: if SOM == null then isEmpty return true, else false.
public
DrawText():bool
<<property>>
Notes: If true, then will be painted RowName of rows from table next to neurons
public
DrawClusters():bool
<<property>>
Notes: if true, then will be painted border between neurons from diferent clusters.
public
DrawClusterID():bool
<<property>>
Notes: if true, then will be painted cluster ID of neuron.
public
DrawingRectangle(
   int left,
   int right,
   int top,
   int bottom):void
Notes: set of rectangle for drawing
private
CalculateHexagonPosition():void
Notes: Calculate position of hexagons
private
ClearTextField():void
Notes: Remove Row Name from neurons.
private
SetNeurons():void
Notes: Set neurons
private
SetDistance():void
Notes: Set distance between neurons
private
SetClustersSeparators():void
Notes: Set cluster separators
private
SetColors():void
Notes: Set colors for all hexagons in U-matrix. Colors are normalized for interval (0, mostDistancedNeuron)
private
SetDescriptiveText():void
Notes: Set descriptive text (Row name). Get all rows from table, and for every row find nearest neuron. For this neuron add row name to Hexagon.Text properties. Set descriptive text is very demanding operation. Complexity of this operation is O(M*N), whre M is count of neurons in networks and N is count of entries in table.
public
getPoint(
   int index,
   int width,
   int height):Point
Notes: Convert point in one dimensional array to two dimensional posision in array with "width" x "height" size

@returns
private
FindWinner(
   double[] vector):int
Notes: Find the nearest neuron for given vector

@returns index of winner neurons
public
Distance(
   double[] vector,
   double[] weights):double
Notes: Calculate Euclidian distance between tvo vectors

@returns
private
NormalizedColor(
   Color bottomColor,
   Color topColor,
   double dist,
   double max):Color
Notes: Normalized color. BottomColor is maped to 0 and TopColor is maped to max. Color between them are liner maped to interval (0, max).

@returns color for dist parameter
private
FindMaxDistance():double
Notes: Run through array of hexagon, and find the maximum distance between neurons

@returns maximum distance
private
GetHexagonVertex(
   PointF position,
   float a,
   float b):PointF
Notes: Return a position of hexagon vertex

@returns array of hexagon vertex
public
Draw(
   Graphics grfx):void
Notes: Draw U-matrix
public
Draw(
   Graphics grfx,
   int top,
   int left,
   int bottom,
   int right):void
Notes: Draw U-matrix