File Coverage

blib/lib/AI/NeuralNet/FastSOM.pm
Criterion Covered Total %
statement 19 20 95.0
branch 4 4 100.0
condition n/a
subroutine 6 7 85.7
pod 0 4 0.0
total 29 35 82.8


line stmt bran cond sub pod time code
1             package AI::NeuralNet::FastSOM;
2              
3 11     11   18069 use strict;
  11         20  
  11         391  
4 11     11   50 use warnings;
  11         17  
  11         329  
5 11     11   54 use XSLoader;
  11         28  
  11         3391  
6              
7             our $VERSION = '0.19';
8              
9 0     0 0 0 sub new { die 'Dont use this class directly' }
10              
11             sub label {
12 3     3 0 568 my ($self, $x, $y, $l) = @_;
13             return defined $l
14             ? $self->{labels}->[$x]->[$y] = $l
15 3 100       35 : $self->{labels}->[$x]->[$y];
16             }
17              
18             sub value {
19 90     90 0 19462 my ($self, $x, $y, $v) = @_;
20             return defined $v
21             ? $self->{map}[$x][$y] = $v
22 90 100       1447 : $self->{map}[$x][$y];
23             }
24              
25             sub mean_error {
26 162     162 0 54488 my $self = shift;
27 162         155 my $error = 0;
28 486         717 map { $error += $_ } # then add them all up
29 162         244 map { ( $self->bmu($_) )[2] } # then find the distance
  486         2634  
30             @_; # take all data vectors
31 162         495 return ($error / scalar @_); # return the mean value
32             }
33              
34             XSLoader::load(__PACKAGE__);
35              
36             1;
37              
38             __END__