AI-ML

 view release on metacpan or  search on metacpan

Build.PL  view on Meta::CPAN

    "Module::Build" => "0.28"
  },
  "dist_abstract" => "Perl interface to ML",
  "dist_author" => [
    "Rui Meira <ruimiguelcm96\@gmail.com>"
  ],
  "dist_name" => "AI-ML",
  "dist_version" => "0.001",
  "license" => "perl",
  "module_name" => "AI::ML",
  "recursive_test_files" => 1,
  "test_requires" => {
    "ExtUtils::MakeMaker" => 0,
    "File::Spec" => 0,
    "Test2::V0" => "0.000060",
    "Test::More" => 0
  }
);


my %fallback_build_requires = (
  "ExtUtils::MakeMaker" => 0,
  "File::Spec" => 0,
  "Module::Build" => "0.28",
  "Test2::V0" => "0.000060",
  "Test::More" => 0
);


unless ( eval { Module::Build->VERSION(0.4004) } ) {
  delete $module_build_args{test_requires};
  $module_build_args{build_requires} = \%fallback_build_requires;
}

my $build = MyBuilder->new(%module_build_args);


$build->create_build_script;

LICENSE  view on Meta::CPAN

OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

        Appendix: How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.

  To do so, attach the following notices to the program.  It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.

    <one line to give the program's name and a brief idea of what it does.>

META.json  view on Meta::CPAN

      },
      "develop" : {
         "requires" : {
            "File::Spec" : "0",
            "IO::Handle" : "0",
            "IPC::Open3" : "0",
            "Test::More" : "0",
            "Test::Pod" : "1.41"
         }
      },
      "test" : {
         "recommends" : {
            "CPAN::Meta" : "2.120900"
         },
         "requires" : {
            "ExtUtils::MakeMaker" : "0",
            "File::Spec" : "0",
            "Test2::V0" : "0.000060",
            "Test::More" : "0"
         }
      }

META.json  view on Meta::CPAN

                  "default_jobs" : 1
               }
            },
            "name" : "ModuleBuild",
            "version" : "6.010"
         },
         {
            "class" : "Dist::Zilla::Plugin::Prereqs",
            "config" : {
               "Dist::Zilla::Plugin::Prereqs" : {
                  "phase" : "test",
                  "type" : "requires"
               }
            },
            "name" : "TestRequires",
            "version" : "6.010"
         },
         {
            "class" : "Dist::Zilla::Plugin::Git::GatherDir",
            "config" : {
               "Dist::Zilla::Plugin::GatherDir" : {

META.yml  view on Meta::CPAN

      class: Dist::Zilla::Plugin::ModuleBuild
      config:
        Dist::Zilla::Role::TestRunner:
          default_jobs: 1
      name: ModuleBuild
      version: '6.010'
    -
      class: Dist::Zilla::Plugin::Prereqs
      config:
        Dist::Zilla::Plugin::Prereqs:
          phase: test
          type: requires
      name: TestRequires
      version: '6.010'
    -
      class: Dist::Zilla::Plugin::Git::GatherDir
      config:
        Dist::Zilla::Plugin::GatherDir:
          exclude_filename: []
          exclude_match: []
          follow_symlinks: 0

run.sh  view on Meta::CPAN

#!/bin/bash

dzil build;
cd AI-ML-0.001;
perl Build.PL --with-double;
./Build
./Build test

scripts/mnist.pl  view on Meta::CPAN


use Math::Lapack;
use Math::Lapack::Matrix;

use AI::ML;
use AI::ML::NeuralNetwork;
    
my %opt = (
        "train-images" => "train-images-idx3-ubyte",
        "train-labels" => "train-labels-idx1-ubyte",
        "test-images"  => "t10k-images-idx3-ubyte",
        "test-labels"  => "t10k-labels-idx1-ubyte"
    );


_load_data();


sub _load_data {
    _download_data();
    # compile c file
    system("gcc load_data.c -o load");

t/00-report-prereqs.dd  view on Meta::CPAN

                      },
       'develop' => {
                      'requires' => {
                                      'File::Spec' => '0',
                                      'IO::Handle' => '0',
                                      'IPC::Open3' => '0',
                                      'Test::More' => '0',
                                      'Test::Pod' => '1.41'
                                    }
                    },
       'test' => {
                   'recommends' => {
                                     'CPAN::Meta' => '2.120900'
                                   },
                   'requires' => {
                                   'ExtUtils::MakeMaker' => '0',
                                   'File::Spec' => '0',
                                   'Test2::V0' => '0.000060',
                                   'Test::More' => '0'
                                 }
                 }

t/00-report-prereqs.t  view on Meta::CPAN

#!perl

use strict;
use warnings;

# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.027

use Test::More tests => 1;

use ExtUtils::MakeMaker;
use File::Spec;

# from $version::LAX
my $lax_version_re =
    qr/(?: undef | (?: (?:[0-9]+) (?: \. | (?:\.[0-9]+) (?:_[0-9]+)? )?
            |
            (?:\.[0-9]+) (?:_[0-9]+)?
        ) | (?:

t/00-report-prereqs.t  view on Meta::CPAN


my @full_reports;
my @dep_errors;
my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs;

# Add static includes into a fake section
for my $mod (@include) {
    $req_hash->{other}{modules}{$mod} = 0;
}

for my $phase ( qw(configure build test runtime develop other) ) {
    next unless $req_hash->{$phase};
    next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING});

    for my $type ( qw(requires recommends suggests conflicts modules) ) {
        next unless $req_hash->{$phase}{$type};

        my $title = ucfirst($phase).' '.ucfirst($type);
        my @reports = [qw/Module Want Have/];

        for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) {

t/01-activation-funcs.t  view on Meta::CPAN

#!perl

use Test2::V0 qw'is float done_testing';
use Math::Lapack::Matrix;
use Math::Lapack::Expr;
use AI::ML::Expr;

use Data::Dumper;


my $m = Math::Lapack::Matrix->new(
				[ 
					[0, 0.002, 3, 4, 7.333, -.00008, -2.03456, 9, 100.3456, -300] 

t/01-activation-funcs.t  view on Meta::CPAN

_float($soft->get_element(2,1), 0.24178252, "Element correct at 2,1");
_float($soft->get_element(3,1), 0.65723302, "Element correct at 3,1");

#prob of third col
_float($soft->get_element(0,2), 0.00626879, "Element correct at 0,2");
_float($soft->get_element(1,2), 0.01704033, "Element correct at 1,2");
_float($soft->get_element(2,2), 0.04632042, "Element correct at 2,2");
_float($soft->get_element(3,2), 0.93037047, "Element correct at 3,2");


done_testing;

sub _float {
  my ($a, $b, $c) = @_;
	is($a, float($b, tolerance => 0.00001), $c);
}

t/02-cost_functions.t  view on Meta::CPAN

#!perl

use Math::Lapack::Matrix;
use Math::Lapack::Expr;
use AI::ML::Expr;

my $m_1 = Math::Lapack::Matrix->new([ [-2, 1, 2, 3] ]);
my $nr_tests = 0;

#Test d_relu
my $a = d_relu($m_1);

float($a->get_element(0,0), 0, "Element correct at 0,0");
float($a->get_element(0,1), 1, "Element correct at 0,1");
float($a->get_element(0,2), 1, "Element correct at 0,2");
float($a->get_element(0,3), 1, "Element correct at 0,3");

my $b = $a x $m_1->transpose;

float($b->get_element(0,0), 6, "Element correct at 0,0");

print "1..$nr_tests\n";

sub float {
  $nr_tests++;
  my ($a, $b, $explanation) = @_;
  if (abs($a-$b) > 0.000001){
    print "not ";
    $explanation .= " ($a vs $b)";
  }
  print "ok $nr_tests - $explanation\n";
}

sub is {
  $nr_tests++;
  my ($a, $b, $explanation) = @_;
  if ($a != $b){
    print "not ";
    $explanation .= " ($a vs $b)";
  }
  print "ok $nr_tests - $explanation\n";
}

t/03-mini-batch.t  view on Meta::CPAN

#!perl

use Math::Lapack::Matrix;
use Math::Lapack::Expr;
use AI::ML::Expr;

my $m = Math::Lapack::Matrix->random(50,1000);
my $nr_tests = 0;
my $axis = 0;
my $size = 200;
my $start = 0;

for my $v (0..4){
    my $a = mini_batch($m, $start, $size, $axis);
    is($a->rows, 50, "Right number of rows\n");
    is($a->columns, 200, "Right number of columns\n");
    $start += $size;    
}

t/03-mini-batch.t  view on Meta::CPAN

my $m_1 = Math::Lapack::Matrix->random(1000,20);
$start = 0;
$axis = 1;
for my $i (0..4){
    my $b = mini_batch($m_1, $start, $size, $axis);
    is($b->rows, 200, "Right number of rows\n");
    is($b->columns, 20, "Right number of columns\n");
    $start += $size;    
}
    
print "1..$nr_tests\n";

sub float {
  $nr_tests++;
  my ($a, $b, $explanation) = @_;
  if (abs($a-$b) > 0.000001){
    print "not ";
    $explanation .= " ($a vs $b)";
  }
  print "ok $nr_tests - $explanation\n";
}

sub is {
  $nr_tests++;
  my ($a, $b, $explanation) = @_;
  if ($a != $b){
    print "not ";
    $explanation .= " ($a vs $b)";
  }
  print "ok $nr_tests - $explanation\n";
}

t/04-linear-regression.t  view on Meta::CPAN

                                             gradient => "foo",
                                             plot     => "../../plot2.png",
                                             n        => 50,
                                             alpha    => 0.001);
$n->train($x, $y);
is($n->{thetas}->rows, 2, "Right number of rows");
is($n->{thetas}->columns, 1, "Right number of columns");

_float($n->{thetas}->get_element(0,0), 0.78473628, "Normal Equation - Right value of theta 0,0");
_float($n->{thetas}->get_element(1,0), 0.83133813, "Normal Equation - Right value of theta 1,0");
### FIXME: if the tests generate files, you should test them.
##         and delete them afterwads

done_testing();

sub _float {
    my ($a, $b, $c) = @_;
    is($a, float($b, tolerance => 0.000001), $c);
}

t/05-logistic-regression.t  view on Meta::CPAN

#!perl

use Test2::V0 qw'is float done_testing';
use Math::Lapack::Matrix;
use Math::Lapack;
use AI::ML::LogisticRegression;

Math::Lapack->seed_rng(0);

my $x = Math::Lapack::Matrix::read_csv("t/logistic.csv", col_range =>[0,2]);
my $y = Math::Lapack::Matrix::read_csv("t/logistic.csv", col => 3);


t/05-logistic-regression.t  view on Meta::CPAN

_float($thetas->get_element(3,0), 0.60950995, "Right vale of theta 3,0");


$n->prediction($x);
_float($n->accuracy($y), 0.7450980392156863, "Right value of accuracy");
_float($n->precision($y), 0.5652173913043478, "Right value of precision");
_float($n->recall($y), 0.16049382716049382, "Right value of recall");
_float($n->f1($y), .25, "Right value of f1");


done_testing;

sub _float {
    my ($a, $b, $c) = @_;
	is($a, float($b, tolerance => 0.01), $c);
}

t/06-accuracy-precision-recall-f1.t  view on Meta::CPAN

#!perl

use Math::Lapack::Matrix;
use AI::ML::Expr;

my $nr_tests=0;
my $y = Math::Lapack::Matrix->new([
				[1],[0],[1],[1],[0],[0],[1],[1],[1],[1],[0],[0],[1],[0],[0]
		]);
my $yatt = Math::Lapack::Matrix->new([
				[1],[0],[0],[0],[1],[1],[0],[1],[1],[1],[1],[0],[0],[0],[0]
		]);

# True Positive = 4
# False Positive = 3
# False Negative = 4

t/06-accuracy-precision-recall-f1.t  view on Meta::CPAN


my $prec = AI::ML::Expr::precision($y, $yatt);
float($prec, 0.571428571, "Right Precision");

my $rec = AI::ML::Expr::recall($y, $yatt);
float($rec, 0.5, "Right recall");

my $f_1 = AI::ML::Expr::f1($y, $yatt);
float($f_1, 0.533333334, "Right f1");

print "1..$nr_tests\n";

sub float {
  $nr_tests++;
  my ($a, $b, $explanation) = @_;
  if (abs($a-$b) > 0.000001){
    print "not ";
    $explanation .= " ($a vs $b)";
  }
  print "ok $nr_tests - $explanation\n";
}

sub is {
  $nr_tests++;
  my ($a, $b, $explanation) = @_;
  if ($a != $b){
    print "not ";
    $explanation .= " ($a vs $b)";
  }
  print "ok $nr_tests - $explanation\n";
}

t/07-neural-network.t  view on Meta::CPAN

#!perl

use Test2::V0 qw'is float done_testing';
use Math::Lapack::Matrix;
use AI::ML::NeuralNetwork;
use Math::Lapack;
use Data::Dumper;


Math::Lapack->seed_rng(0);

my $x = Math::Lapack::Matrix::read_csv("t/x.csv");
my $y = Math::Lapack::Matrix::read_csv("t/y.csv");

t/07-neural-network.t  view on Meta::CPAN

        $pred->get_element(0, $_),
        "Right element on 0,$_"
    );
}

_float($NN->accuracy($y), 0.98, "Right accuracy");
_float($NN->precision($y), 0.970588235294118, "Right precision");
_float($NN->recall($y), .99, "Right recall");
_float($NN->f1($y), 0.98019801980198, "Right F1");

done_testing();

sub _float {
  my ($a, $b, $c) = @_;
	is($a, float($b, tolerance => 0.1), $c);
}

t/08-gradient-checking.t_  view on Meta::CPAN

#!perl

use Test2::V0 qw'is float done_testing';
use Math::Lapack::Matrix;
use AI::ML::NeuralNetwork;
use Math::Lapack;
use Data::Dumper;


Math::Lapack->seed_rng(0);

#my $x = Math::Lapack::Matrix::read_csv("t/logistic.csv", col_range =>[0,2]);
#my $y = Math::Lapack::Matrix::read_csv("t/logistic.csv", col => 3);

t/08-gradient-checking.t_  view on Meta::CPAN

#
#print STDERR "Accuracy: $acc\n";
#print STDERR "Precison: $prec\n";
#print STDERR "Recall: $rec\n";
#print STDERR "F1: $f1\n";

#my $t1 = $NN->{"l1"}{w};
#$t1->save_matlab("/tmp/t0.m");
#print STDERR Dumper($NN->{"l1"}{w});

done_testing;

sub _float {
  my ($a, $b, $c) = @_;
	is($a, float($b, tolerance => 0.01), $c);
}

xt/author/00-compile.t  view on Meta::CPAN

use 5.006;
use strict;
use warnings;

# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058

use Test::More;

plan tests => 6;

my @module_files = (
    'AI/ML.pm',
    'AI/ML/Expr.pm',
    'AI/ML/LinearRegression.pm',
    'AI/ML/LogisticRegression.pm',
    'AI/ML/NeuralNetwork.pm'
);




( run in 0.547 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )