AI-Perceptron
view release on metacpan or search on metacpan
lib/AI/Perceptron.pm view on Meta::CPAN
}
sub add_example {
shift->add_examples(@_);
}
sub compute_output {
my $self = shift;
my @inputs = @_;
my $sum = $self->threshold; # start at threshold
for my $i (0 .. $self->num_inputs-1) {
$sum += $self->weights->[$i] * $inputs[$i];
}
# binary (returning the real $sum is not part of this model)
return ($sum > 0) ? 1 : -1;
}
##
# $p->train( [ @training_examples ] )
( run in 0.372 second using v1.01-cache-2.11-cpan-0d8aa00de5b )