NAME

AI::NeuralNet::Kohonen::Visual - Tk-based Visualisation

SYNOPSIS

Test the test file in this distribution, or:

package YourClass;
use base "AI::NeuralNet::Kohonen::Visual";

sub get_colour_for { my ($self,$x,$y) = (shift,shift,shift);
	# From here you return a TK colour name.
	# Get it as you please; for example, values of a 3D map:
	return sprintf("#%02x%02x%02x",
		(int (255 * $self->{map}->[$x]->[$y]->{weight}->[0])),
		(int (255 * $self->{map}->[$x]->[$y]->{weight}->[1])),
		(int (255 * $self->{map}->[$x]->[$y]->{weight}->[2])),
	);
}

exit;
1;

And then:

use YourClass;
my $net = AI::NeuralNet::Kohonen::Visual->new(
	display          => 'hex',
	map_dim          => 39,
	epochs           => 19,
	neighbour_factor => 2,
	targeting        => 1,
	table            => "3
		1 0 0 red
		0 1 0 yellow
		0 0 1 blue
		0 1 1 cyan
		1 1 0 yellow
		1 .5 0 orange
		1 .5 1 pink",
);
$net->train;
$net->plot_map;
$net->main_loop;

exit;

DESCRIPTION

Provides TK-based visualisation routines for AI::NueralNet::Kohonen. Replaces the earlier AI::NeuralNet::Kohonen::Demo::RGB.

This is a sub-class of AI::NeuralNet::Kohonen that impliments extra methods to make use of TK.

This moudle is itself intended to be sub-classed by you, where you provide a version of the method get_colour_for: see "METHOD get_colour_for" and SYNOPSIS for details.

CONSTRUCTOR (new)

The following paramter fields are added to the base module's fields:

display

Set to hex for display as a unified distance matrix, rather than as the default plain grid;

display_scale

Set with a factor to effect the size of the display.

show_bmu

Show the current BMU during training.

show_training

Display updates during training.

label_bmu
label_all

Displays labels...

MainLoop

Calls TK's MainLoop at the end of training.

missing_colour

When selecting a colour using "METHOD get_colour_for", every node weight holding the value of missing_mask will be given the value of this paramter. If this paramter is not defined, the default is 0.

METHOD train

Over-rides the base class to provide TK displays of the map.

METHOD get_colour_for

This method is intended to be sub-classed.

Currently it only operates on the first three elements of a weight vector, turning them into RGB values.

It returns the a TK colour for a node at position x,y in the map paramter.

Accepts: x and y co-ordinates in the map.

METHOD prepare_display

Depracated: see "METHOD create_empty_map".

METHOD create_empty_map

Sets up a TK MainWindow and Canvas to act as an empty map.

METHOD plot_map

Plots the map on the existing canvas. Arguments are supplied in a hash with the following keys as options:

The values of bmu_x and bmu_y represent The x and y co-ordinates of unit to highlight using the value in the hicol to highlight it with colour. If no hicolo is provided, it default to red.

When called, this method also sets the object field flag plotted: currently, this prevents main_loop from calling this routine.

See also "METHOD get_colour_for".

METHOD label_map

Put a text label on the map for the node at the x,y co-ordinates supplied in the first two paramters, using the text supplied in the third.

Very naive: no attempt to check the text will appear on the map.

METHOD main_loop

Calls TK's MainLoop to keep a window open until the user closes it.

SEE ALSO

See AI::NeuralNet::Kohonen; AI::NeuralNet::Kohonen::Node;

AUTHOR AND COYRIGHT

This implimentation Copyright (C) Lee Goddard, 2003. All Rights Reserved.

Available under the same terms as Perl itself.