AI-NeuralNet-SOM
view release on metacpan or search on metacpan
lib/AI/NeuralNet/SOM.pm view on Meta::CPAN
print I<$nn>->as_string
This methods creates a pretty-print version of the current vectors.
=cut
sub as_string { die; }
=pod
=item I<as_data>
print I<$nn>->as_data
This methods creates a string containing the raw vector data, row by
row. This can be fed into gnuplot, for instance.
=cut
sub as_data { die; }
=pod
=back
=head1 HOWTOs
=over
=item I<using Eigenvectors to initialize the SOM>
See the example script in the directory C<examples> provided in the
distribution. It uses L<PDL> (for speed and scalability, but the
results are not as good as I had thought).
=item I<loading and saving a SOM>
See the example script in the directory C<examples>. It uses
C<Storable> to directly dump the data structure onto disk. Storage and
retrieval is quite fast.
=back
=head1 FAQs
=over
=item I<I get 'uninitialized value ...' warnings, many of them>
There is most likely something wrong with the C<input_dim> you
specified and your vectors should be having.
=back
=head1 TODOs
=over
=item maybe implement the SOM on top of PDL?
=item provide a ::SOM::Compat to have compatibility with the original AI::NeuralNet::SOM?
=item implement different window forms (bubble/gaussian), linear/random
=item implement the format mentioned in the original AI::NeuralNet::SOM
=item add methods as_html to individual topologies
=item add iterators through vector lists for I<initialize> and I<train>
=back
=head1 SUPPORT
Bugs should always be submitted via the CPAN bug tracker
L<https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=AI-NeuralNet-SOM>
=head1 SEE ALSO
Explanation of the algorithm:
L<http://www.ai-junkie.com/ann/som/som1.html>
Old version of AI::NeuralNet::SOM from Alexander Voischev:
L<http://backpan.perl.org/authors/id/V/VO/VOISCHEV/>
Subclasses:
L<AI::NeuralNet::Hexa>
L<AI::NeuralNet::Rect>
L<AI::NeuralNet::Torus>
=head1 AUTHOR
Robert Barta, E<lt>rho@devc.atE<gt>
=head1 COPYRIGHT AND LICENSE
Copyright (C) 200[78] by Robert Barta
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.
=cut
our $VERSION = '0.07';
1;
__END__
sub bmu {
my $self = shift;
my $sample = shift;
my $closest; # [x,y, distance] value and co-ords of closest match
foreach my $coor ($self->_get_coordinates) { # generate all coord pairs, not overly happy with that
my ($x, $y) = @$coor;
my $distance = _vector_distance ($self->{map}->[$x]->[$y], $sample); # || Vi - Sample ||
$closest = [0, 0, $distance] unless $closest;
$closest = [$x, $y, $distance] if $distance < $closest->[2];
( run in 0.924 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )