Algorithm-AdaBoost

 view release on metacpan or  search on metacpan

inc/Module/Install.pm  view on Meta::CPAN

	open( FH, "< $_[0]"  ) or die "open($_[0]): $!";
	my $string = do { local $/; <FH> };
	close FH or die "close($_[0]): $!";
	return $string;
}
END_OLD

sub _readperl {
	my $string = Module::Install::_read($_[0]);
	$string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg;
	$string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s;
	$string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg;
	return $string;
}

sub _readpod {
	my $string = Module::Install::_read($_[0]);
	$string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg;
	return $string if $_[0] =~ /\.pod\z/;
	$string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg;
	$string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg;

t/01_basic.t  view on Meta::CPAN

use 5.014;

use Algorithm::AdaBoost;
use Smart::Args;
use Test::More;

my @dataset = map {
  chomp;
  my ($label, $x, $y) = split /\s/;
  +{ feature => [$x, $y], label => $label };
} <DATA>;

my @training_set = @dataset[0 .. 99];
my @test_set = @dataset[100 .. 199];

my $learner = new_ok 'Algorithm::AdaBoost' => [
  training_set => \@training_set,
  weak_classifier_generator => \&generate_weak_classifier,
];
ok(
  +(not $learner->trained),

t/01_basic.t  view on Meta::CPAN

    for my $i (0 .. $#$distribution) {
      my $answer = $classifier_candidate->($training_set->[$i]{feature});
      $accuracy += $distribution->[$i] if $answer == $training_set->[$i]{label};
    }
    return $classifier_candidate if $accuracy > 1/2;
  }
}

# f(x, y) = 1 if x^2 + y^2 < 4, -1 otherwise.
# subject to -3 <= x < 3, -3 <= y < 3.
__DATA__
1 -0.248490100750111 -0.739693407357834
1 -0.566115592376427 -1.68714313853555
1 -0.399623250750217 1.33407775536753
-1 1.39932333014989 2.54595589010434
-1 -2.09890668052825 -2.26928674627152
-1 -1.35789686105749 -2.76051974907672
1 0.0495294874471526 -0.961790183534873
-1 -2.14562371189552 2.51764233416243
1 1.27731540363029 0.241831210669432
1 1.16150264946072 1.49304025338465

xt/01_podspell.t  view on Meta::CPAN

use Test::More;
eval q{ use Test::Spelling };
plan skip_all => "Test::Spelling is not installed." if $@;
add_stopwords(map { split /[\s\:\-]/ } <DATA>);
$ENV{LANG} = 'C';
all_pod_files_spelling_ok('lib');
__DATA__
Koichi SATOH
sekia@cpan.org
Algorithm::AdaBoost



( run in 1.110 second using v1.01-cache-2.11-cpan-140bd7fdf52 )