AI::NeuralNet::Kohonen::Visual - Tk-based Visualisation
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;
Provides TK-based visualisation routines for AI::NueralNet::Kohonen. Replaces the earlier AI::NeuralNet::Kohonen::Demo::RGB.
AI::NueralNet::Kohonen
AI::NeuralNet::Kohonen::Demo::RGB
This is a sub-class of AI::NeuralNet::Kohonen that impliments extra methods to make use of TK.
AI::NeuralNet::Kohonen
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.
get_colour_for
The following paramter fields are added to the base module's fields:
Set to hex for display as a unified distance matrix, rather than as the default plain grid;
hex
Set with a factor to effect the size of the display.
Show the current BMU during training.
Display updates during training.
Displays labels...
Calls TK's MainLoop at the end of training.
MainLoop
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.
missing_mask
Over-rides the base class to provide TK displays of the map.
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.
x
y
map
Accepts: x and y co-ordinates in the map.
Depracated: see "METHOD create_empty_map".
Sets up a TK MainWindow and Canvas to act as an empty map.
MainWindow
Canvas
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.
bmu_x
bmu_y
hicol
hicolo
When called, this method also sets the object field flag plotted: currently, this prevents main_loop from calling this routine.
plotted
main_loop
See also "METHOD get_colour_for".
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.
Calls TK's MainLoop to keep a window open until the user closes it.
See AI::NeuralNet::Kohonen; AI::NeuralNet::Kohonen::Node;
This implimentation Copyright (C) Lee Goddard, 2003. All Rights Reserved.
Available under the same terms as Perl itself.
To install AI::NeuralNet::Kohonen::Visual, copy and paste the appropriate command in to your terminal.
cpanm
cpanm AI::NeuralNet::Kohonen::Visual
CPAN shell
perl -MCPAN -e shell install AI::NeuralNet::Kohonen::Visual
For more information on module installation, please visit the detailed CPAN module installation guide.