line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AI::XGBoost; |
2
|
1
|
|
|
1
|
|
48051
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
244
|
use AI::XGBoost::Booster; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Exporter::Easy ( OK => ['train'] ); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.11'; # VERSION |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Perl wrapper for XGBoost library L |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub train { |
13
|
|
|
|
|
|
|
my %args = @_; |
14
|
|
|
|
|
|
|
my ( $params, $data, $number_of_rounds ) = @args{qw(params data number_of_rounds)}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $booster = AI::XGBoost::Booster->new( cache => [$data] ); |
17
|
|
|
|
|
|
|
if ( defined $params ) { |
18
|
|
|
|
|
|
|
while ( my ( $name, $value ) = each %$params ) { |
19
|
|
|
|
|
|
|
$booster->set_param( $name, $value ); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
for my $iteration ( 0 .. $number_of_rounds - 1 ) { |
23
|
|
|
|
|
|
|
$booster->update( dtrain => $data, iteration => $iteration ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
return $booster; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
1; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
__END__ |