| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package AI::XGBoost::CAPI::RAW; | 
| 2 | 3 |  |  | 3 |  | 188182 | use strict; | 
|  | 3 |  |  |  |  | 7 |  | 
|  | 3 |  |  |  |  | 100 |  | 
| 3 | 3 |  |  | 3 |  | 18 | use warnings; | 
|  | 3 |  |  |  |  | 10 |  | 
|  | 3 |  |  |  |  | 105 |  | 
| 4 |  |  |  |  |  |  |  | 
| 5 | 3 |  |  | 3 |  | 648 | use parent 'NativeCall'; | 
|  | 3 |  |  |  |  | 684 |  | 
|  | 3 |  |  |  |  | 17 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | our $VERSION = '0.008';    # VERSION | 
| 8 |  |  |  |  |  |  |  | 
| 9 |  |  |  |  |  |  | # ABSTRACT: Perl wrapper for XGBoost C API https://github.com/dmlc/xgboost | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 3 |  |  | 3 |  | 33174 | sub XGBGetLastError : Args() : Native(xgboost) : Returns(string) { } | 
|  | 3 |  |  | 0 |  | 3648 |  | 
|  | 3 |  |  |  |  | 21 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | sub XGDMatrixCreateFromFile : Args(string, int, opaque*) : Native(xgboost) : Returns(int) { } | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | sub XGDMatrixCreateFromCSREx : Args(size_t[], uint[], float[], size_t, size_t, size_t, opaque*) : Native(xgboost) : | 
| 16 |  |  |  |  |  |  | Returns(int) { } | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | sub XGDMatrixCreateFromCSCEx : Args(size_t[], uint[], float[], size_t, size_t, size_t, opaque*) : Native(xgboost) : | 
| 19 |  |  |  |  |  |  | Returns(int) { } | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | sub XGDMatrixCreateFromMat : Args(float[], uint64, uint64, float, opaque*) : Native(xgboost) : Returns(int) { } | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub XGDMatrixSliceDMatrix : Args(opaque, int *, uint64, opaque*) : Native(xgboost) : Returns(int) { } | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | sub XGDMatrixNumRow : Args(opaque, uint64*) : Native(xgboost) : Returns(int) { } | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | sub XGDMatrixNumCol : Args(opaque, uint64*) : Native(xgboost) : Returns(int) { } | 
| 28 |  |  |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | sub XGDMatrixSaveBinary : Args(opaque, string, int) : Native(xgboost) : Returns(int) { } | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | sub XGDMatrixSetFloatInfo : Args(opaque, string, float[], uint64) : Native(xgboost) : Returns(int) { } | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | sub XGDMatrixSetUIntInfo : Args(opaque, string, uint32 *, uint64) : Native(xgboost) : Returns(int) { } | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | sub XGDMatrixSetGroup : Args(opaque, uint32 *, uint64) : Native(xgboost) : Returns(int) { } | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | sub XGDMatrixGetFloatInfo : Args(opaque, string, uint64 *, opaque *) : Native(xgboost) : Returns(int) { } | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | sub XGDMatrixGetUIntInfo : Args(opaque, string, uint64 *, opaque *) : Native(xgboost) : Returns(int) { } | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | sub XGDMatrixFree : Args(opaque) : Native(xgboost) : Returns(int) { } | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | sub XGBoosterCreate : Args(opaque[], uint64, opaque*) : Native(xgboost) : Returns(int) { } | 
| 44 |  |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | sub XGBoosterFree : Args(opaque) : Native(xgboost) : Returns(int) { } | 
| 46 |  |  |  |  |  |  |  | 
| 47 |  |  |  |  |  |  | sub XGBoosterSetParam : Args(opaque, string, string) : Native(xgboost) : Returns(int) { } | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | sub XGBoosterBoostOneIter : Args(opaque, opaque, float[], float[], uint64) : Native(xgboost) : Returns(int) { } | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | sub XGBoosterUpdateOneIter : Args(opaque, int, opaque) : Native(xgboost) : Returns(int) { } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub XGBoosterEvalOneIter : Args(opaque, int, opaque[], opaque[], uint64, opaque*) : Native(xgboost) : Returns(int) { } | 
| 54 |  |  |  |  |  |  |  | 
| 55 |  |  |  |  |  |  | sub XGBoosterPredict : Args(opaque, opaque, int, uint, uint64*, opaque*) : Native(xgboost) : Returns(int) { } | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | sub XGBoosterLoadModel : Args(opaque, string) : Native(xgboost) : Returns(int) { } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | sub XGBoosterSaveModel : Args(opaque, string) : Native(xgboost) : Returns(int) { } | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | sub XGBoosterLoadModelFromBuffer : Args(opaque, opaque, uint64) : Native(xgboost) : Returns(int) { } | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | sub XGBoosterGetModelRaw : Args(opaque, uint64*, opaque*) : Native(xgboost) : Returns(int) { } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | sub XGBoosterDumpModel : Args(opaque, string, int, uint64*, opaque*) : Native(xgboost) : Returns(int) { } | 
| 66 |  |  |  |  |  |  |  | 
| 67 |  |  |  |  |  |  | sub XGBoosterDumpModelEx : Args(opaque, string, int, string, uint64*, opaque*) : Native(xgboost) : Returns(int) { } | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | sub XGBoosterDumpModelWithFeatures : Args(opaque, int, opaque[], opaque[], int, uint64*, opaque*) Native(xgboost) : | 
| 70 |  |  |  |  |  |  | Returns(int) { } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | sub XGBoosterDumpModelExWithFeatures : Args(opaque, int, opaque[], opaque[], int, string, uint64*, opaque*) | 
| 73 |  |  |  |  |  |  | Native(xgboost) : Returns(int) { } | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  | sub XGBoosterSetAttr : Args(opaque, string, string) : Native(xgboost) : Returns(int) { } | 
| 76 |  |  |  |  |  |  |  | 
| 77 |  |  |  |  |  |  | sub XGBoosterGetAttr : Args(opaque, string, opaque*, int*) : Native(xgboost) : Returns(int) { } | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | sub XGBoosterGetAttrNames : Args(opaque, uint64*, opaque*) : Native(xgboost) : Returns(int) { } | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  | 1; | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | __END__ | 
| 84 |  |  |  |  |  |  |  | 
| 85 |  |  |  |  |  |  | =pod | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | =encoding utf-8 | 
| 88 |  |  |  |  |  |  |  | 
| 89 |  |  |  |  |  |  | =head1 NAME | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW - Perl wrapper for XGBoost C API https://github.com/dmlc/xgboost | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | =head1 VERSION | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | version 0.008 | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | use 5.010; | 
| 100 |  |  |  |  |  |  | use AI::XGBoost::CAPI::RAW; | 
| 101 |  |  |  |  |  |  | use FFI::Platypus; | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | my $silent = 0; | 
| 104 |  |  |  |  |  |  | my ($dtrain, $dtest) = (0, 0); | 
| 105 |  |  |  |  |  |  |  | 
| 106 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGDMatrixCreateFromFile('agaricus.txt.test', $silent, \$dtest); | 
| 107 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGDMatrixCreateFromFile('agaricus.txt.train', $silent, \$dtrain); | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | my ($rows, $cols) = (0, 0); | 
| 110 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGDMatrixNumRow($dtrain, \$rows); | 
| 111 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGDMatrixNumCol($dtrain, \$cols); | 
| 112 |  |  |  |  |  |  | say "Dimensions: $rows, $cols"; | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | my $booster = 0; | 
| 115 |  |  |  |  |  |  |  | 
| 116 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGBoosterCreate( [$dtrain] , 1, \$booster); | 
| 117 |  |  |  |  |  |  |  | 
| 118 |  |  |  |  |  |  | for my $iter (0 .. 10) { | 
| 119 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGBoosterUpdateOneIter($booster, $iter, $dtrain); | 
| 120 |  |  |  |  |  |  | } | 
| 121 |  |  |  |  |  |  |  | 
| 122 |  |  |  |  |  |  | my $out_len = 0; | 
| 123 |  |  |  |  |  |  | my $out_result = 0; | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGBoosterPredict($booster, $dtest, 0, 0, \$out_len, \$out_result); | 
| 126 |  |  |  |  |  |  | my $ffi = FFI::Platypus->new(); | 
| 127 |  |  |  |  |  |  | my $predictions = $ffi->cast(opaque => "float[$out_len]", $out_result); | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | #say join "\n", @$predictions; | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGBoosterFree($booster); | 
| 132 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGDMatrixFree($dtrain); | 
| 133 |  |  |  |  |  |  | AI::XGBoost::CAPI::RAW::XGDMatrixFree($dtest); | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | Wrapper for the C API. | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | The doc for the methods is extracted from doxygen comments: https://github.com/dmlc/xgboost/blob/master/include/xgboost/c_api.h | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =head1 FUNCTIONS | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =head2 XGBGetLastError | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | Get string message of the last error | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | All functions in this file will return 0 when success | 
| 148 |  |  |  |  |  |  | and -1 when an error occurred, | 
| 149 |  |  |  |  |  |  | XGBGetLastError can be called to retrieve the error | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | This function is thread safe and can be called by different thread | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | Returns string error information | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | =head2 XGDMatrixCreateFromFile | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | Load a data matrix | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | Parameters: | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | =over 4 | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  | =item filename | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  | the name of the file | 
| 166 |  |  |  |  |  |  |  | 
| 167 |  |  |  |  |  |  | =item silent | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  | whether print messages during loading | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  | =item out | 
| 172 |  |  |  |  |  |  |  | 
| 173 |  |  |  |  |  |  | a loaded data matrix | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | =back | 
| 176 |  |  |  |  |  |  |  | 
| 177 |  |  |  |  |  |  | =head2 XGDMatrixCreateFromCSREx | 
| 178 |  |  |  |  |  |  |  | 
| 179 |  |  |  |  |  |  | Create a matrix content from CSR fromat | 
| 180 |  |  |  |  |  |  |  | 
| 181 |  |  |  |  |  |  | Parameters: | 
| 182 |  |  |  |  |  |  |  | 
| 183 |  |  |  |  |  |  | =over 4 | 
| 184 |  |  |  |  |  |  |  | 
| 185 |  |  |  |  |  |  | =item indptr | 
| 186 |  |  |  |  |  |  |  | 
| 187 |  |  |  |  |  |  | pointer to row headers | 
| 188 |  |  |  |  |  |  |  | 
| 189 |  |  |  |  |  |  | =item indices | 
| 190 |  |  |  |  |  |  |  | 
| 191 |  |  |  |  |  |  | findex | 
| 192 |  |  |  |  |  |  |  | 
| 193 |  |  |  |  |  |  | =item data | 
| 194 |  |  |  |  |  |  |  | 
| 195 |  |  |  |  |  |  | fvalue | 
| 196 |  |  |  |  |  |  |  | 
| 197 |  |  |  |  |  |  | =item nindptr | 
| 198 |  |  |  |  |  |  |  | 
| 199 |  |  |  |  |  |  | number of rows in the matrix + 1 | 
| 200 |  |  |  |  |  |  |  | 
| 201 |  |  |  |  |  |  | =item nelem | 
| 202 |  |  |  |  |  |  |  | 
| 203 |  |  |  |  |  |  | number of nonzero elements in the matrix | 
| 204 |  |  |  |  |  |  |  | 
| 205 |  |  |  |  |  |  | =item num_col | 
| 206 |  |  |  |  |  |  |  | 
| 207 |  |  |  |  |  |  | number of columns; when it's set to 0, then guess from data | 
| 208 |  |  |  |  |  |  |  | 
| 209 |  |  |  |  |  |  | =item out | 
| 210 |  |  |  |  |  |  |  | 
| 211 |  |  |  |  |  |  | created dmatrix | 
| 212 |  |  |  |  |  |  |  | 
| 213 |  |  |  |  |  |  | =back | 
| 214 |  |  |  |  |  |  |  | 
| 215 |  |  |  |  |  |  | =head2 XGDMatrixCreateFromCSCEx | 
| 216 |  |  |  |  |  |  |  | 
| 217 |  |  |  |  |  |  | Create a matrix content from CSC format | 
| 218 |  |  |  |  |  |  |  | 
| 219 |  |  |  |  |  |  | Parameters: | 
| 220 |  |  |  |  |  |  |  | 
| 221 |  |  |  |  |  |  | =over 4 | 
| 222 |  |  |  |  |  |  |  | 
| 223 |  |  |  |  |  |  | =item col_ptr | 
| 224 |  |  |  |  |  |  |  | 
| 225 |  |  |  |  |  |  | pointer to col headers | 
| 226 |  |  |  |  |  |  |  | 
| 227 |  |  |  |  |  |  | =item indices | 
| 228 |  |  |  |  |  |  |  | 
| 229 |  |  |  |  |  |  | findex | 
| 230 |  |  |  |  |  |  |  | 
| 231 |  |  |  |  |  |  | =item data | 
| 232 |  |  |  |  |  |  |  | 
| 233 |  |  |  |  |  |  | fvalue | 
| 234 |  |  |  |  |  |  |  | 
| 235 |  |  |  |  |  |  | =item nindptr | 
| 236 |  |  |  |  |  |  |  | 
| 237 |  |  |  |  |  |  | number of rows in the matrix + 1 | 
| 238 |  |  |  |  |  |  |  | 
| 239 |  |  |  |  |  |  | =item nelem | 
| 240 |  |  |  |  |  |  |  | 
| 241 |  |  |  |  |  |  | number of nonzero elements in the matrix | 
| 242 |  |  |  |  |  |  |  | 
| 243 |  |  |  |  |  |  | =item num_row | 
| 244 |  |  |  |  |  |  |  | 
| 245 |  |  |  |  |  |  | number of rows; when it's set to 0, then guess from data | 
| 246 |  |  |  |  |  |  |  | 
| 247 |  |  |  |  |  |  | =back | 
| 248 |  |  |  |  |  |  |  | 
| 249 |  |  |  |  |  |  | =head2 XGDMatrixCreateFromMat | 
| 250 |  |  |  |  |  |  |  | 
| 251 |  |  |  |  |  |  | Create matrix content from dense matrix | 
| 252 |  |  |  |  |  |  |  | 
| 253 |  |  |  |  |  |  | Parameters: | 
| 254 |  |  |  |  |  |  |  | 
| 255 |  |  |  |  |  |  | =over 4 | 
| 256 |  |  |  |  |  |  |  | 
| 257 |  |  |  |  |  |  | =item data | 
| 258 |  |  |  |  |  |  |  | 
| 259 |  |  |  |  |  |  | pointer to the data space | 
| 260 |  |  |  |  |  |  |  | 
| 261 |  |  |  |  |  |  | =item nrow | 
| 262 |  |  |  |  |  |  |  | 
| 263 |  |  |  |  |  |  | number of rows | 
| 264 |  |  |  |  |  |  |  | 
| 265 |  |  |  |  |  |  | =item ncol | 
| 266 |  |  |  |  |  |  |  | 
| 267 |  |  |  |  |  |  | number columns | 
| 268 |  |  |  |  |  |  |  | 
| 269 |  |  |  |  |  |  | =item missing | 
| 270 |  |  |  |  |  |  |  | 
| 271 |  |  |  |  |  |  | which value to represent missing value | 
| 272 |  |  |  |  |  |  |  | 
| 273 |  |  |  |  |  |  | =item out | 
| 274 |  |  |  |  |  |  |  | 
| 275 |  |  |  |  |  |  | created dmatrix | 
| 276 |  |  |  |  |  |  |  | 
| 277 |  |  |  |  |  |  | =back | 
| 278 |  |  |  |  |  |  |  | 
| 279 |  |  |  |  |  |  | =head2 XGDMatrixSliceDMatrix | 
| 280 |  |  |  |  |  |  |  | 
| 281 |  |  |  |  |  |  | Create a new dmatrix from sliced content of existing matrix | 
| 282 |  |  |  |  |  |  |  | 
| 283 |  |  |  |  |  |  | Parameters: | 
| 284 |  |  |  |  |  |  |  | 
| 285 |  |  |  |  |  |  | =over 4 | 
| 286 |  |  |  |  |  |  |  | 
| 287 |  |  |  |  |  |  | =item handle | 
| 288 |  |  |  |  |  |  |  | 
| 289 |  |  |  |  |  |  | instance of data matrix to be sliced | 
| 290 |  |  |  |  |  |  |  | 
| 291 |  |  |  |  |  |  | =item idxset | 
| 292 |  |  |  |  |  |  |  | 
| 293 |  |  |  |  |  |  | index set | 
| 294 |  |  |  |  |  |  |  | 
| 295 |  |  |  |  |  |  | =item len | 
| 296 |  |  |  |  |  |  |  | 
| 297 |  |  |  |  |  |  | length of index set | 
| 298 |  |  |  |  |  |  |  | 
| 299 |  |  |  |  |  |  | =item out | 
| 300 |  |  |  |  |  |  |  | 
| 301 |  |  |  |  |  |  | a sliced new matrix | 
| 302 |  |  |  |  |  |  |  | 
| 303 |  |  |  |  |  |  | =back | 
| 304 |  |  |  |  |  |  |  | 
| 305 |  |  |  |  |  |  | =head2 XGDMatrixNumRow | 
| 306 |  |  |  |  |  |  |  | 
| 307 |  |  |  |  |  |  | Get number of rows. | 
| 308 |  |  |  |  |  |  |  | 
| 309 |  |  |  |  |  |  | Parameters: | 
| 310 |  |  |  |  |  |  |  | 
| 311 |  |  |  |  |  |  | =over 4 | 
| 312 |  |  |  |  |  |  |  | 
| 313 |  |  |  |  |  |  | =item handle | 
| 314 |  |  |  |  |  |  |  | 
| 315 |  |  |  |  |  |  | the handle to the DMatrix | 
| 316 |  |  |  |  |  |  |  | 
| 317 |  |  |  |  |  |  | =item out | 
| 318 |  |  |  |  |  |  |  | 
| 319 |  |  |  |  |  |  | The address to hold number of rows. | 
| 320 |  |  |  |  |  |  |  | 
| 321 |  |  |  |  |  |  | =back | 
| 322 |  |  |  |  |  |  |  | 
| 323 |  |  |  |  |  |  | =head2 XGDMatrixNumCol | 
| 324 |  |  |  |  |  |  |  | 
| 325 |  |  |  |  |  |  | Get number of cols. | 
| 326 |  |  |  |  |  |  |  | 
| 327 |  |  |  |  |  |  | Parameters: | 
| 328 |  |  |  |  |  |  |  | 
| 329 |  |  |  |  |  |  | =over 4 | 
| 330 |  |  |  |  |  |  |  | 
| 331 |  |  |  |  |  |  | =item handle | 
| 332 |  |  |  |  |  |  |  | 
| 333 |  |  |  |  |  |  | the handle to the DMatrix | 
| 334 |  |  |  |  |  |  |  | 
| 335 |  |  |  |  |  |  | =item out | 
| 336 |  |  |  |  |  |  |  | 
| 337 |  |  |  |  |  |  | The address to hold number of cols. | 
| 338 |  |  |  |  |  |  |  | 
| 339 |  |  |  |  |  |  | =back | 
| 340 |  |  |  |  |  |  |  | 
| 341 |  |  |  |  |  |  | =head2 XGDMatrixSaveBinary | 
| 342 |  |  |  |  |  |  |  | 
| 343 |  |  |  |  |  |  | load a data matrix into binary file | 
| 344 |  |  |  |  |  |  |  | 
| 345 |  |  |  |  |  |  | Parameters: | 
| 346 |  |  |  |  |  |  |  | 
| 347 |  |  |  |  |  |  | =over 4 | 
| 348 |  |  |  |  |  |  |  | 
| 349 |  |  |  |  |  |  | =item handle | 
| 350 |  |  |  |  |  |  |  | 
| 351 |  |  |  |  |  |  | a instance of data matrix | 
| 352 |  |  |  |  |  |  |  | 
| 353 |  |  |  |  |  |  | =item fname | 
| 354 |  |  |  |  |  |  |  | 
| 355 |  |  |  |  |  |  | file name | 
| 356 |  |  |  |  |  |  |  | 
| 357 |  |  |  |  |  |  | =item silent | 
| 358 |  |  |  |  |  |  |  | 
| 359 |  |  |  |  |  |  | print statistics when saving | 
| 360 |  |  |  |  |  |  |  | 
| 361 |  |  |  |  |  |  | =back | 
| 362 |  |  |  |  |  |  |  | 
| 363 |  |  |  |  |  |  | =head2 XGDMatrixSetFloatInfo | 
| 364 |  |  |  |  |  |  |  | 
| 365 |  |  |  |  |  |  | Set float vector to a content in info | 
| 366 |  |  |  |  |  |  |  | 
| 367 |  |  |  |  |  |  | Parameters: | 
| 368 |  |  |  |  |  |  |  | 
| 369 |  |  |  |  |  |  | =over 4 | 
| 370 |  |  |  |  |  |  |  | 
| 371 |  |  |  |  |  |  | =item handle | 
| 372 |  |  |  |  |  |  |  | 
| 373 |  |  |  |  |  |  | a instance of data matrix | 
| 374 |  |  |  |  |  |  |  | 
| 375 |  |  |  |  |  |  | =item field | 
| 376 |  |  |  |  |  |  |  | 
| 377 |  |  |  |  |  |  | field name, can be label, weight | 
| 378 |  |  |  |  |  |  |  | 
| 379 |  |  |  |  |  |  | =item array | 
| 380 |  |  |  |  |  |  |  | 
| 381 |  |  |  |  |  |  | pointer to float vector | 
| 382 |  |  |  |  |  |  |  | 
| 383 |  |  |  |  |  |  | =item len | 
| 384 |  |  |  |  |  |  |  | 
| 385 |  |  |  |  |  |  | length of array | 
| 386 |  |  |  |  |  |  |  | 
| 387 |  |  |  |  |  |  | =back | 
| 388 |  |  |  |  |  |  |  | 
| 389 |  |  |  |  |  |  | =head2 XGDMatrixSetUIntInfo | 
| 390 |  |  |  |  |  |  |  | 
| 391 |  |  |  |  |  |  | Set uint32 vector to a content in info | 
| 392 |  |  |  |  |  |  |  | 
| 393 |  |  |  |  |  |  | Parameters: | 
| 394 |  |  |  |  |  |  |  | 
| 395 |  |  |  |  |  |  | =over 4 | 
| 396 |  |  |  |  |  |  |  | 
| 397 |  |  |  |  |  |  | =item handle | 
| 398 |  |  |  |  |  |  |  | 
| 399 |  |  |  |  |  |  | a instance of data matrix | 
| 400 |  |  |  |  |  |  |  | 
| 401 |  |  |  |  |  |  | =item field | 
| 402 |  |  |  |  |  |  |  | 
| 403 |  |  |  |  |  |  | field name, can be label, weight | 
| 404 |  |  |  |  |  |  |  | 
| 405 |  |  |  |  |  |  | =item array | 
| 406 |  |  |  |  |  |  |  | 
| 407 |  |  |  |  |  |  | pointer to unsigned int vector | 
| 408 |  |  |  |  |  |  |  | 
| 409 |  |  |  |  |  |  | =item len | 
| 410 |  |  |  |  |  |  |  | 
| 411 |  |  |  |  |  |  | length of array | 
| 412 |  |  |  |  |  |  |  | 
| 413 |  |  |  |  |  |  | =back | 
| 414 |  |  |  |  |  |  |  | 
| 415 |  |  |  |  |  |  | =head2 XGDMatrixSetGroup | 
| 416 |  |  |  |  |  |  |  | 
| 417 |  |  |  |  |  |  | Set label of the training matrix | 
| 418 |  |  |  |  |  |  |  | 
| 419 |  |  |  |  |  |  | Parameters: | 
| 420 |  |  |  |  |  |  |  | 
| 421 |  |  |  |  |  |  | =over 4 | 
| 422 |  |  |  |  |  |  |  | 
| 423 |  |  |  |  |  |  | =item handle | 
| 424 |  |  |  |  |  |  |  | 
| 425 |  |  |  |  |  |  | a instance of data matrix | 
| 426 |  |  |  |  |  |  |  | 
| 427 |  |  |  |  |  |  | =item group | 
| 428 |  |  |  |  |  |  |  | 
| 429 |  |  |  |  |  |  | pointer to group size | 
| 430 |  |  |  |  |  |  |  | 
| 431 |  |  |  |  |  |  | =item len | 
| 432 |  |  |  |  |  |  |  | 
| 433 |  |  |  |  |  |  | length of the array | 
| 434 |  |  |  |  |  |  |  | 
| 435 |  |  |  |  |  |  | =back | 
| 436 |  |  |  |  |  |  |  | 
| 437 |  |  |  |  |  |  | =head2 XGDMatrixGetFloatInfo | 
| 438 |  |  |  |  |  |  |  | 
| 439 |  |  |  |  |  |  | Get float info vector from matrix | 
| 440 |  |  |  |  |  |  |  | 
| 441 |  |  |  |  |  |  | Parameters: | 
| 442 |  |  |  |  |  |  |  | 
| 443 |  |  |  |  |  |  | =over 4 | 
| 444 |  |  |  |  |  |  |  | 
| 445 |  |  |  |  |  |  | =item handle | 
| 446 |  |  |  |  |  |  |  | 
| 447 |  |  |  |  |  |  | a instance of data matrix | 
| 448 |  |  |  |  |  |  |  | 
| 449 |  |  |  |  |  |  | =item field | 
| 450 |  |  |  |  |  |  |  | 
| 451 |  |  |  |  |  |  | field name | 
| 452 |  |  |  |  |  |  |  | 
| 453 |  |  |  |  |  |  | =item out_len | 
| 454 |  |  |  |  |  |  |  | 
| 455 |  |  |  |  |  |  | used to set result length | 
| 456 |  |  |  |  |  |  |  | 
| 457 |  |  |  |  |  |  | =item out_dptr | 
| 458 |  |  |  |  |  |  |  | 
| 459 |  |  |  |  |  |  | pointer to the result | 
| 460 |  |  |  |  |  |  |  | 
| 461 |  |  |  |  |  |  | =back | 
| 462 |  |  |  |  |  |  |  | 
| 463 |  |  |  |  |  |  | =head2 XGDMatrixGetUIntInfo | 
| 464 |  |  |  |  |  |  |  | 
| 465 |  |  |  |  |  |  | Get uint32 info vector from matrix | 
| 466 |  |  |  |  |  |  |  | 
| 467 |  |  |  |  |  |  | Parameters: | 
| 468 |  |  |  |  |  |  |  | 
| 469 |  |  |  |  |  |  | =over 4 | 
| 470 |  |  |  |  |  |  |  | 
| 471 |  |  |  |  |  |  | =item handle | 
| 472 |  |  |  |  |  |  |  | 
| 473 |  |  |  |  |  |  | a instance of data matrix | 
| 474 |  |  |  |  |  |  |  | 
| 475 |  |  |  |  |  |  | =item field | 
| 476 |  |  |  |  |  |  |  | 
| 477 |  |  |  |  |  |  | field name | 
| 478 |  |  |  |  |  |  |  | 
| 479 |  |  |  |  |  |  | =item out_len | 
| 480 |  |  |  |  |  |  |  | 
| 481 |  |  |  |  |  |  | The length of the field | 
| 482 |  |  |  |  |  |  |  | 
| 483 |  |  |  |  |  |  | =item out_dptr | 
| 484 |  |  |  |  |  |  |  | 
| 485 |  |  |  |  |  |  | pointer to the result | 
| 486 |  |  |  |  |  |  |  | 
| 487 |  |  |  |  |  |  | =back | 
| 488 |  |  |  |  |  |  |  | 
| 489 |  |  |  |  |  |  | =head2 XGDMatrixFree | 
| 490 |  |  |  |  |  |  |  | 
| 491 |  |  |  |  |  |  | Free space in data matrix | 
| 492 |  |  |  |  |  |  |  | 
| 493 |  |  |  |  |  |  | =head2 XGBoosterCreate | 
| 494 |  |  |  |  |  |  |  | 
| 495 |  |  |  |  |  |  | Create xgboost learner | 
| 496 |  |  |  |  |  |  |  | 
| 497 |  |  |  |  |  |  | Parameters: | 
| 498 |  |  |  |  |  |  |  | 
| 499 |  |  |  |  |  |  | =over 4 | 
| 500 |  |  |  |  |  |  |  | 
| 501 |  |  |  |  |  |  | =item dmats | 
| 502 |  |  |  |  |  |  |  | 
| 503 |  |  |  |  |  |  | matrices that are set to be cached | 
| 504 |  |  |  |  |  |  |  | 
| 505 |  |  |  |  |  |  | =item len | 
| 506 |  |  |  |  |  |  |  | 
| 507 |  |  |  |  |  |  | length of dmats | 
| 508 |  |  |  |  |  |  |  | 
| 509 |  |  |  |  |  |  | =item out | 
| 510 |  |  |  |  |  |  |  | 
| 511 |  |  |  |  |  |  | handle to the result booster | 
| 512 |  |  |  |  |  |  |  | 
| 513 |  |  |  |  |  |  | =back | 
| 514 |  |  |  |  |  |  |  | 
| 515 |  |  |  |  |  |  | =head2 XGBoosterFree | 
| 516 |  |  |  |  |  |  |  | 
| 517 |  |  |  |  |  |  | Free obj in handle | 
| 518 |  |  |  |  |  |  |  | 
| 519 |  |  |  |  |  |  | Parameters: | 
| 520 |  |  |  |  |  |  |  | 
| 521 |  |  |  |  |  |  | =over 4 | 
| 522 |  |  |  |  |  |  |  | 
| 523 |  |  |  |  |  |  | =item handle | 
| 524 |  |  |  |  |  |  |  | 
| 525 |  |  |  |  |  |  | handle to be freed | 
| 526 |  |  |  |  |  |  |  | 
| 527 |  |  |  |  |  |  | =back | 
| 528 |  |  |  |  |  |  |  | 
| 529 |  |  |  |  |  |  | =head2 XGBoosterSetParam | 
| 530 |  |  |  |  |  |  |  | 
| 531 |  |  |  |  |  |  | Update the model in one round using dtrain | 
| 532 |  |  |  |  |  |  |  | 
| 533 |  |  |  |  |  |  | Parameters: | 
| 534 |  |  |  |  |  |  |  | 
| 535 |  |  |  |  |  |  | =over 4 | 
| 536 |  |  |  |  |  |  |  | 
| 537 |  |  |  |  |  |  | =item handle | 
| 538 |  |  |  |  |  |  |  | 
| 539 |  |  |  |  |  |  | handle | 
| 540 |  |  |  |  |  |  |  | 
| 541 |  |  |  |  |  |  | =item name | 
| 542 |  |  |  |  |  |  |  | 
| 543 |  |  |  |  |  |  | parameter name | 
| 544 |  |  |  |  |  |  |  | 
| 545 |  |  |  |  |  |  | =item value | 
| 546 |  |  |  |  |  |  |  | 
| 547 |  |  |  |  |  |  | value of parameter | 
| 548 |  |  |  |  |  |  |  | 
| 549 |  |  |  |  |  |  | =back | 
| 550 |  |  |  |  |  |  |  | 
| 551 |  |  |  |  |  |  | =head2 XGBoosterBoostOneIter | 
| 552 |  |  |  |  |  |  |  | 
| 553 |  |  |  |  |  |  | Update the modelo, by directly specify grandient and second order gradient, | 
| 554 |  |  |  |  |  |  | this can be used to replace UpdateOneIter, to support customized loss function | 
| 555 |  |  |  |  |  |  |  | 
| 556 |  |  |  |  |  |  | Parameters: | 
| 557 |  |  |  |  |  |  |  | 
| 558 |  |  |  |  |  |  | =over 4 | 
| 559 |  |  |  |  |  |  |  | 
| 560 |  |  |  |  |  |  | =item handle | 
| 561 |  |  |  |  |  |  |  | 
| 562 |  |  |  |  |  |  | handle | 
| 563 |  |  |  |  |  |  |  | 
| 564 |  |  |  |  |  |  | =item dtrain | 
| 565 |  |  |  |  |  |  |  | 
| 566 |  |  |  |  |  |  | training data | 
| 567 |  |  |  |  |  |  |  | 
| 568 |  |  |  |  |  |  | =item grad | 
| 569 |  |  |  |  |  |  |  | 
| 570 |  |  |  |  |  |  | gradient statistics | 
| 571 |  |  |  |  |  |  |  | 
| 572 |  |  |  |  |  |  | =item hess | 
| 573 |  |  |  |  |  |  |  | 
| 574 |  |  |  |  |  |  | second order gradinet statistics | 
| 575 |  |  |  |  |  |  |  | 
| 576 |  |  |  |  |  |  | =item len | 
| 577 |  |  |  |  |  |  |  | 
| 578 |  |  |  |  |  |  | length of grad/hess array | 
| 579 |  |  |  |  |  |  |  | 
| 580 |  |  |  |  |  |  | =back | 
| 581 |  |  |  |  |  |  |  | 
| 582 |  |  |  |  |  |  | =head2 XGBoosterUpdateOneIter | 
| 583 |  |  |  |  |  |  |  | 
| 584 |  |  |  |  |  |  | Update the model in one round using dtrain | 
| 585 |  |  |  |  |  |  |  | 
| 586 |  |  |  |  |  |  | Parameters: | 
| 587 |  |  |  |  |  |  |  | 
| 588 |  |  |  |  |  |  | =over 4 | 
| 589 |  |  |  |  |  |  |  | 
| 590 |  |  |  |  |  |  | =item handle | 
| 591 |  |  |  |  |  |  |  | 
| 592 |  |  |  |  |  |  | handle | 
| 593 |  |  |  |  |  |  |  | 
| 594 |  |  |  |  |  |  | =item iter | 
| 595 |  |  |  |  |  |  |  | 
| 596 |  |  |  |  |  |  | current iteration rounds | 
| 597 |  |  |  |  |  |  |  | 
| 598 |  |  |  |  |  |  | =item dtrain | 
| 599 |  |  |  |  |  |  |  | 
| 600 |  |  |  |  |  |  | training data | 
| 601 |  |  |  |  |  |  |  | 
| 602 |  |  |  |  |  |  | =back | 
| 603 |  |  |  |  |  |  |  | 
| 604 |  |  |  |  |  |  | =head2 XGBoosterEvalOneIter | 
| 605 |  |  |  |  |  |  |  | 
| 606 |  |  |  |  |  |  | =head2 XGBoosterPredict | 
| 607 |  |  |  |  |  |  |  | 
| 608 |  |  |  |  |  |  | Make prediction based on dmat | 
| 609 |  |  |  |  |  |  |  | 
| 610 |  |  |  |  |  |  | Parameters: | 
| 611 |  |  |  |  |  |  |  | 
| 612 |  |  |  |  |  |  | =over 4 | 
| 613 |  |  |  |  |  |  |  | 
| 614 |  |  |  |  |  |  | =item handle | 
| 615 |  |  |  |  |  |  |  | 
| 616 |  |  |  |  |  |  | handle | 
| 617 |  |  |  |  |  |  |  | 
| 618 |  |  |  |  |  |  | =item dmat | 
| 619 |  |  |  |  |  |  |  | 
| 620 |  |  |  |  |  |  | data matrix | 
| 621 |  |  |  |  |  |  |  | 
| 622 |  |  |  |  |  |  | =item option_mask | 
| 623 |  |  |  |  |  |  |  | 
| 624 |  |  |  |  |  |  | bit-mask of options taken in prediction, possible values | 
| 625 |  |  |  |  |  |  |  | 
| 626 |  |  |  |  |  |  | =over 4 | 
| 627 |  |  |  |  |  |  |  | 
| 628 |  |  |  |  |  |  | =item | 
| 629 |  |  |  |  |  |  |  | 
| 630 |  |  |  |  |  |  | 0: normal prediction | 
| 631 |  |  |  |  |  |  |  | 
| 632 |  |  |  |  |  |  | =item | 
| 633 |  |  |  |  |  |  |  | 
| 634 |  |  |  |  |  |  | 1: output margin instead of transformed value | 
| 635 |  |  |  |  |  |  |  | 
| 636 |  |  |  |  |  |  | =item | 
| 637 |  |  |  |  |  |  |  | 
| 638 |  |  |  |  |  |  | 2: output leaf index of trees instead of leaf value, note leaf index is unique per tree | 
| 639 |  |  |  |  |  |  |  | 
| 640 |  |  |  |  |  |  | =item | 
| 641 |  |  |  |  |  |  |  | 
| 642 |  |  |  |  |  |  | 4: output feature contributions to individual predictions | 
| 643 |  |  |  |  |  |  |  | 
| 644 |  |  |  |  |  |  | =back | 
| 645 |  |  |  |  |  |  |  | 
| 646 |  |  |  |  |  |  | =item ntree_limit | 
| 647 |  |  |  |  |  |  |  | 
| 648 |  |  |  |  |  |  | limit number of trees used for prediction, this is only valid for boosted trees | 
| 649 |  |  |  |  |  |  | when the parameter is set to 0, we will use all the trees | 
| 650 |  |  |  |  |  |  |  | 
| 651 |  |  |  |  |  |  | =item out_len | 
| 652 |  |  |  |  |  |  |  | 
| 653 |  |  |  |  |  |  | used to store length of returning result | 
| 654 |  |  |  |  |  |  |  | 
| 655 |  |  |  |  |  |  | =item out_result | 
| 656 |  |  |  |  |  |  |  | 
| 657 |  |  |  |  |  |  | used to set a pointer to array | 
| 658 |  |  |  |  |  |  |  | 
| 659 |  |  |  |  |  |  | =back | 
| 660 |  |  |  |  |  |  |  | 
| 661 |  |  |  |  |  |  | =head2 XGBoosterLoadModel | 
| 662 |  |  |  |  |  |  |  | 
| 663 |  |  |  |  |  |  | Load model form existing file | 
| 664 |  |  |  |  |  |  |  | 
| 665 |  |  |  |  |  |  | Parameters: | 
| 666 |  |  |  |  |  |  |  | 
| 667 |  |  |  |  |  |  | =over 4 | 
| 668 |  |  |  |  |  |  |  | 
| 669 |  |  |  |  |  |  | =item handle | 
| 670 |  |  |  |  |  |  |  | 
| 671 |  |  |  |  |  |  | handle | 
| 672 |  |  |  |  |  |  |  | 
| 673 |  |  |  |  |  |  | =item fname | 
| 674 |  |  |  |  |  |  |  | 
| 675 |  |  |  |  |  |  | file name | 
| 676 |  |  |  |  |  |  |  | 
| 677 |  |  |  |  |  |  | =back | 
| 678 |  |  |  |  |  |  |  | 
| 679 |  |  |  |  |  |  | =head2 XGBoosterSaveModel | 
| 680 |  |  |  |  |  |  |  | 
| 681 |  |  |  |  |  |  | Save model into existing file | 
| 682 |  |  |  |  |  |  |  | 
| 683 |  |  |  |  |  |  | Parameters: | 
| 684 |  |  |  |  |  |  |  | 
| 685 |  |  |  |  |  |  | =over 4 | 
| 686 |  |  |  |  |  |  |  | 
| 687 |  |  |  |  |  |  | =item handle | 
| 688 |  |  |  |  |  |  |  | 
| 689 |  |  |  |  |  |  | handle | 
| 690 |  |  |  |  |  |  |  | 
| 691 |  |  |  |  |  |  | =item fname | 
| 692 |  |  |  |  |  |  |  | 
| 693 |  |  |  |  |  |  | file name | 
| 694 |  |  |  |  |  |  |  | 
| 695 |  |  |  |  |  |  | =back | 
| 696 |  |  |  |  |  |  |  | 
| 697 |  |  |  |  |  |  | =head2 XGBoosterLoadModelFromBuffer | 
| 698 |  |  |  |  |  |  |  | 
| 699 |  |  |  |  |  |  | =head2 XGBoosterGetModelRaw | 
| 700 |  |  |  |  |  |  |  | 
| 701 |  |  |  |  |  |  | =head2 XGBoosterDumpModel | 
| 702 |  |  |  |  |  |  |  | 
| 703 |  |  |  |  |  |  | =head2 XGBoosterDumpModelEx | 
| 704 |  |  |  |  |  |  |  | 
| 705 |  |  |  |  |  |  | =head2 XGBoosterDumpModelWithFeatures | 
| 706 |  |  |  |  |  |  |  | 
| 707 |  |  |  |  |  |  | =head2 XGBoosterDumpModelExWithFeatures | 
| 708 |  |  |  |  |  |  |  | 
| 709 |  |  |  |  |  |  | =head2 XGBoosterSetAttr | 
| 710 |  |  |  |  |  |  |  | 
| 711 |  |  |  |  |  |  | =head2 XGBoosterGetAttr | 
| 712 |  |  |  |  |  |  |  | 
| 713 |  |  |  |  |  |  | =head2 XGBoosterGetAttrNames | 
| 714 |  |  |  |  |  |  |  | 
| 715 |  |  |  |  |  |  | =head1 AUTHOR | 
| 716 |  |  |  |  |  |  |  | 
| 717 |  |  |  |  |  |  | Pablo RodrÃguez González <pablo.rodriguez.gonzalez@gmail.com> | 
| 718 |  |  |  |  |  |  |  | 
| 719 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 720 |  |  |  |  |  |  |  | 
| 721 |  |  |  |  |  |  | This software is Copyright (c) 2017 by Pablo RodrÃguez González. | 
| 722 |  |  |  |  |  |  |  | 
| 723 |  |  |  |  |  |  | This is free software, licensed under: | 
| 724 |  |  |  |  |  |  |  | 
| 725 |  |  |  |  |  |  | The Apache License, Version 2.0, January 2004 | 
| 726 |  |  |  |  |  |  |  | 
| 727 |  |  |  |  |  |  | =cut |