AI-MaxEntropy
view release on metacpan or search on metacpan
t/01-samples.t view on Meta::CPAN
use strict;
use warnings;
use Test::More tests => 10;
use Test::Number::Delta within => 1e-5;
my $__;
sub NAME { $__ = shift };
###
NAME 'Load the module';
BEGIN { use_ok 'AI::MaxEntropy' }
###
NAME 'Create a Maximum Entropy Leaner';
my $me = AI::MaxEntropy->new;
ok $me,
$__;
###
NAME 'Add a sample';
$me->see(['round', 'red'] => 'tomato');
is_deeply
[
$me->{samples},
$me->{x_bucket},
$me->{y_bucket},
$me->{x_list},
$me->{y_list},
$me->{x_num},
$me->{y_num},
$me->{f_num},
$me->{af_num},
$me->{f_freq},
$me->{f_map},
$me->{last_cut}
],
[
[ [ [ 0, 1 ] => 0 => 1 ] ],
{ round => 0, red => 1 },
{ tomato => 0 },
[ 'round', 'red' ],
[ 'tomato' ],
2,
1,
0,
2,
[[1, 1]],
[],
-1
],
$__;
###
NAME 'Cut #1';
$me->cut(0);
is_deeply
[
$me->{f_num},
$me->{f_map},
$me->{last_cut}
],
[
2,
[ [0, 1] ],
( run in 0.591 second using v1.01-cache-2.11-cpan-39bf76dae61 )