AI-XGBoost
view release on metacpan or search on metacpan
lib/AI/XGBoost/CAPI.pm view on Meta::CPAN
=encoding utf-8
=head1 NAME
AI::XGBoost::CAPI - Perl wrapper for XGBoost C API https://github.com/dmlc/xgboost
=head1 VERSION
version 0.11
=head1 SYNOPSIS
use 5.010;
use AI::XGBoost::CAPI qw(:all);
my $dtrain = XGDMatrixCreateFromFile('agaricus.txt.train');
my $dtest = XGDMatrixCreateFromFile('agaricus.txt.test');
my ($rows, $cols) = (XGDMatrixNumRow($dtrain), XGDMatrixNumCol($dtrain));
say "Train dimensions: $rows, $cols";
my $booster = XGBoosterCreate([$dtrain]);
for my $iter (0 .. 10) {
XGBoosterUpdateOneIter($booster, $iter, $dtrain);
}
my $predictions = XGBoosterPredict($booster, $dtest);
# say join "\n", @$predictions;
XGBoosterFree($booster);
XGDMatrixFree($dtrain);
XGDMatrixFree($dtest);
=head1 DESCRIPTION
Perlified wrapper for the C API
=head2 Error handling
XGBoost c api functions returns some int to signal the presence/absence of error.
In this module that is achieved using Exceptions from L<Exception::Class>
=head1 FUNCTIONS
=head2 XGDMatrixCreateFromFile
Load a data matrix
Parameters:
=over 4
=item filename
the name of the file
=item silent
whether print messages during loading
=back
Returns a loaded data matrix
=head2 XGDMatrixCreateFromMat
Create from dense matrix
Parameters:
=over 4
=item matrix
matrix data
=item missing
value indicating missing data (optional)
=back
Returns a loaded data matrix
=head2 XGDMatrixNumRow
Get number of rows
Parameters:
=over 4
=item matrix
DMatrix
=back
=head2 XGDMatrixNumCol
Get number of cols
Parameters:
=over 4
=item matrix
DMatrix
=back
=head2 XGDMatrixSetFloatInfo
=head2 XGDMatrixGetFloatInfo
=head2 XGDMatrixSetUintInfo
=head2 XGDMatrixGetUintInfo
( run in 4.130 seconds using v1.01-cache-2.11-cpan-c966e8aa7e8 )