view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
'Text::Matrix' => '1.00',
'YAML' => '0',
'File::Basename' => '0',
'List::Util' => '0',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'AI-Perceptron-Simple-*' },
);
# Compatibility with old versions of ExtUtils::MakeMaker
unless (eval { ExtUtils::MakeMaker->VERSION('6.64'); 1 }) {
my $test_requires = delete $WriteMakefileArgs{TEST_REQUIRES} || {};
@{$WriteMakefileArgs{PREREQ_PM}}{keys %$test_requires} = values %$test_requires;
}
unless (eval { ExtUtils::MakeMaker->VERSION('6.55_03'); 1 }) {
my $build_requires = delete $WriteMakefileArgs{BUILD_REQUIRES} || {};
@{$WriteMakefileArgs{PREREQ_PM}}{keys %$build_requires} = values %$build_requires;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION('6.52'); 1 };
delete $WriteMakefileArgs{MIN_PERL_VERSION}
unless eval { ExtUtils::MakeMaker->VERSION('6.48'); 1 };
delete $WriteMakefileArgs{LICENSE}
unless eval { ExtUtils::MakeMaker->VERSION('6.31'); 1 };
WriteMakefile(%WriteMakefileArgs);
t/00-manifest.t view on Meta::CPAN
use 5.006;
use strict;
use warnings;
use Test::More;
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
my $min_tcm = 0.9;
eval "use Test::CheckManifest $min_tcm";
plan skip_all => "Test::CheckManifest $min_tcm required" if $@;
ok_manifest();
t/00-pod-coverage.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;
all_pod_coverage_ok();
use strict;
use warnings;
use Test::More;
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
all_pod_files_ok();
t/02-creation.t view on Meta::CPAN
# get_attributes()
my %attributes = $perceptron->get_attributes;
for ( @attributes ) {
ok( $attributes{ $_ }, "Attribute \'$_\' present" );
is( $attributes{ $_ }, $initial_value, "Correct initial value (".$attributes{$_}.") for \'$_\'" );
}
# don't try to use Test::Carp, it won't work, it only tests for direct calling of carp and croak etc
subtest "Caught missing mandatory parameters" => sub {
eval {
my $no_attribs = AI::Perceptron::Simple->new( { initial_value => $initial_value} );
};
like( $@, qr/attribs/, "Caught missing attribs" );
eval {
my $perceptron = AI::Perceptron::Simple->new( { attribs => \@attributes} );
};
like($@, qr/initial_value/, "Caught missing initial_value");
#my $no_both = AI::Perceptron::Simple->new; # this will fail and give output to use hash ref, nice
eval { my $no_both = AI::Perceptron::Simple->new( {} ); };
like( $@, qr/Missing keys: initial_value attribs/, "Caught missing initial_value and attribs" );
};
done_testing();
# besiyata d'shmaya
t/04-train.t view on Meta::CPAN
# print $FindBin::Bin, "\n";
# print TRAINING_DATA, "\n";
ok ( -e TRAINING_DATA, "Found the training file" );
# saving and loading - this should go into a new test script
my $nerve_file = $FindBin::Bin . "/perceptron_1.nerve";
#ok( $perceptron->train( TRAINING_DATA, "brand", $nerve_file, WANT_STATS, IDENTIFIER ), "No problem with \'train\' method so far" );
{
local $@ = "";
eval { $perceptron->train( TRAINING_DATA, "brand", $nerve_file, WANT_STATS, IDENTIFIER) };
is ( $@, "", "No problem with \'train\' method (verbose) so far" );
}
ok ( $perceptron->train( TRAINING_DATA, "brand", $nerve_file), "No problem with \'train\' method (non-verbose) so far" );
# no longer returns the file anymore since v0.03
# is ( $perceptron->train( TRAINING_DATA, "brand", $nerve_file), $nerve_file, "\'train\' method returns the correct value" );
subtest "Data related subroutine found" => sub {
ok( AI::Perceptron::Simple->can("save_perceptron"), "&save_perceptron is persent" );
t/04-train_synonyms_exercise.t view on Meta::CPAN
# print $FindBin::Bin, "\n";
# print TRAINING_DATA, "\n";
ok ( -e TRAINING_DATA, "Found the training file" );
# saving and loading - this should go into a new test script
my $nerve_file = $FindBin::Bin . "/perceptron_exercise.nerve";
#ok( $perceptron->train( TRAINING_DATA, "brand", $nerve_file, WANT_STATS, IDENTIFIER ), "No problem with \'train\' method so far" );
{
local $@ = "";
eval { $perceptron->train( TRAINING_DATA, "brand", $nerve_file, WANT_STATS, IDENTIFIER) };
is ( $@, "", "No problem with \'train\' method (verbose) so far" );
}
ok ( $perceptron->train( TRAINING_DATA, "brand", $nerve_file), "No problem with \'train\' method (non-verbose) so far" );
# no longer returns the file anymore since v0.03
# is ( $perceptron->train( TRAINING_DATA, "brand", $nerve_file), $nerve_file, "\'train\' method returns the correct value" );
ok( AI::Perceptron::Simple->can("save_perceptron"), "&save_perceptron is persent" );
ok( AI::Perceptron::Simple->can("load_perceptron"), "&loaded_perceptron is present" );
t/04-train_synonyms_tame.t view on Meta::CPAN
# print $FindBin::Bin, "\n";
# print TRAINING_DATA, "\n";
ok ( -e TRAINING_DATA, "Found the training file" );
# saving and loading - this should go into a new test script
my $nerve_file = $FindBin::Bin . "/perceptron_tame.nerve";
#ok( $perceptron->train( TRAINING_DATA, "brand", $nerve_file, WANT_STATS, IDENTIFIER ), "No problem with \'train\' method so far" );
{
local $@ = "";
eval { $perceptron->train( TRAINING_DATA, "brand", $nerve_file, WANT_STATS, IDENTIFIER) };
is ( $@, "", "No problem with \'train\' method (verbose) so far" );
}
ok ( $perceptron->train( TRAINING_DATA, "brand", $nerve_file), "No problem with \'train\' method (non-verbose) so far" );
# no longer returns the file anymore since v0.03
# is ( $perceptron->train( TRAINING_DATA, "brand", $nerve_file), $nerve_file, "\'train\' method returns the correct value" );
ok( AI::Perceptron::Simple->can("save_perceptron"), "&save_perceptron is persent" );
ok( AI::Perceptron::Simple->can("load_perceptron"), "&loaded_perceptron is present" );
t/08-confusion_matrix.t view on Meta::CPAN
"Testing the 'untestable' &_calculate_accuracy" );
like ( $c_matrix{ accuracy }, qr/60/, "'illegal' calculation of accuracy seems correct to me" );
like ( $c_matrix{ sensitivity }, qr/40/, "Accuracy seems correct to me" );
ok ( AI::Perceptron::Simple::_calculate_sensitivity( \%c_matrix ),
"Testing the 'untestable' &_calculate_sensitivity" );
like ( $c_matrix{ accuracy }, qr/60/, "'illegal' calculation of sensitivity seems correct to me" );
{
local $@;
eval {
$perceptron->get_confusion_matrix( {
full_data_file => NON_BINARY_FILE,
actual_output_header => "brand",
predicted_output_header => "predicted",
} );
};
like ( $@, qr/Something\'s wrong\!/, "Croaked! Found non-binary values in file");
}
t/08-confusion_matrix.t view on Meta::CPAN
ok ( $perceptron->display_exam_results( \%c_matrix, { zero_as => "MP520", one_as => "Yi Lin" } ),
"display_exam_results is working");
} qr /(?:$piece)/, "$piece displayed";
}
{
local $@;
eval {
$perceptron->display_confusion_matrix( \%c_matrix, { one_as => "Yi Lin" } );
};
like ( $@, qr/zero_as/, "Missing keys found: zero_as!" );
unlike ( $@, qr/one_as/, "Confirmed one_as is present but not zero_as" );
}
{
local $@;
eval {
$perceptron->display_confusion_matrix( \%c_matrix, { zero_as => "MP520" } );
};
like ( $@, qr/one_as/, "Missing keys found: one_as!" );
unlike ( $@, qr/zero_as/, "Confirmed zero_as is present but not one_as" );
}
{
local $@;
eval {
$perceptron->display_confusion_matrix( \%c_matrix );
};
like ( $@, qr/zero_as one_as/, "Both keys not found" );
}
# more_stats enabled
subtest "More stats" => sub {
t/08-confusion_matrix_synonyms.t view on Meta::CPAN
"Testing the 'untestable' &_calculate_accuracy" );
like ( $c_matrix{ accuracy }, qr/60/, "'illegal' calculation of accuracy seems correct to me" );
like ( $c_matrix{ sensitivity }, qr/40/, "Accuracy seems correct to me" );
ok ( AI::Perceptron::Simple::_calculate_sensitivity( \%c_matrix ),
"Testing the 'untestable' &_calculate_sensitivity" );
like ( $c_matrix{ accuracy }, qr/60/, "'illegal' calculation of sensitivity seems correct to me" );
{
local $@;
eval {
$perceptron->get_exam_results( {
full_data_file => NON_BINARY_FILE,
actual_output_header => "brand",
predicted_output_header => "predicted",
} );
};
like ( $@, qr/Something\'s wrong\!/, "Croaked! Found non-binary values in file");
}
t/08-confusion_matrix_synonyms.t view on Meta::CPAN
"display_exam_results is working");
} qr /(?:$piece)/, "$piece displayed";
}
{
local $@;
eval {
$perceptron->display_exam_results( \%c_matrix, { one_as => "Yi Lin" } );
};
like ( $@, qr/zero_as/, "Missing keys found: zero_as!" );
unlike ( $@, qr/one_as/, "Confirmed one_as is present but not zero_as" );
}
{
local $@;
eval {
$perceptron->display_exam_results( \%c_matrix, { zero_as => "MP520" } );
};
like ( $@, qr/one_as/, "Missing keys found: one_as!" );
unlike ( $@, qr/zero_as/, "Confirmed zero_as is present but not one_as" );
}
{
local $@;
eval {
$perceptron->display_exam_results( \%c_matrix );
};
like ( $@, qr/zero_as one_as/, "Both keys not found" );
}
# more_stats enabled
subtest "More stats" => sub {
my %c_matrix_more_stats = $perceptron->get_confusion_matrix( {
t/12-shuffle_data.t view on Meta::CPAN
my $original_stimuli = $FindBin::Bin . "/book_list_to_shuffle.csv";
my $shuffled_data_1 = $FindBin::Bin . "/shuffled_1.csv";
my $shuffled_data_2 = $FindBin::Bin . "/shuffled_2.csv";
my $shuffled_data_3 = $FindBin::Bin . "/shuffled_3.csv";
ok( -e $original_stimuli, "Found the original file" );
{
local $@;
eval { shuffle_data };
like( $@, qr/^Please specify/, "Croaked at invocation with any arguements" )
}
{
local $@;
eval { shuffle_data($original_stimuli) };
like( $@, qr/output files/, "Croaked when new file names not present" )
}
shuffle_data( $original_stimuli => $shuffled_data_1, $shuffled_data_2, $shuffled_data_3 );
stdout_like {
shuffle_data( ORIGINAL_STIMULI, $shuffled_data_1, $shuffled_data_2, $shuffled_data_3 );
} qr/^Saved/, "Correct output after saving file";
t/12-shuffle_data_synonym.t view on Meta::CPAN
my $original_stimuli = $FindBin::Bin . "/book_list_to_shuffle.csv";
my $shuffled_data_1 = $FindBin::Bin . "/shuffled_1.csv";
my $shuffled_data_2 = $FindBin::Bin . "/shuffled_2.csv";
my $shuffled_data_3 = $FindBin::Bin . "/shuffled_3.csv";
ok( -e $original_stimuli, "Found the original file" );
{
local $@;
eval { shuffle_stimuli };
like( $@, qr/^Please specify/, "Croaked at invocation with any arguements" )
}
{
local $@;
eval { shuffle_stimuli($original_stimuli) };
like( $@, qr/output files/, "Croaked when new file names not present" )
}
shuffle_stimuli( $original_stimuli => $shuffled_data_1, $shuffled_data_2, $shuffled_data_3 );
stdout_like {
shuffle_stimuli( ORIGINAL_STIMULI, $shuffled_data_1, $shuffled_data_2, $shuffled_data_3 );
} qr/^Saved/, "Correct output after saving file";