xgboost
Classes | Macros | Typedefs | Functions
c_api.h File Reference

C API of XGBoost, used for interfacing to other languages. More...

#include <stdio.h>
#include <stdint.h>
Include dependency graph for c_api.h:

Go to the source code of this file.

Classes

struct  XGBoostBatchCSR
 Mini batch used in XGBoost Data Iteration. More...
 

Macros

#define XGB_EXTERN_C
 
#define XGB_DLL   XGB_EXTERN_C
 

Typedefs

typedef uint64_t bst_ulong
 
typedef void * DMatrixHandle
 handle to DMatrix More...
 
typedef void * BoosterHandle
 handle to Booster More...
 
typedef void * DataIterHandle
 handle to a data iterator More...
 
typedef void * DataHolderHandle
 handle to a internal data holder. More...
 

Functions

XGB_DLL void XGBoostVersion (int *major, int *minor, int *patch)
 Return the version of the XGBoost library being currently used. More...
 
XGB_EXTERN_C typedef int XGBCallbackSetData (DataHolderHandle handle, XGBoostBatchCSR batch)
 Callback to set the data to handle,. More...
 
XGB_EXTERN_C typedef int XGBCallbackDataIterNext (DataIterHandle data_handle, XGBCallbackSetData *set_function, DataHolderHandle set_function_handle)
 The data reading callback function. The iterator will be able to give subset of batch in the data. More...
 
XGB_DLL const char * XGBGetLastError (void)
 get string message of the last error More...
 
XGB_DLL int XGBRegisterLogCallback (void(*callback)(const char *))
 register callback function for LOG(INFO) messages – helpful messages that are not errors. Note: this function can be called by multiple threads. The callback function will run on the thread that registered it More...
 
XGB_DLL int XGDMatrixCreateFromFile (const char *fname, int silent, DMatrixHandle *out)
 load a data matrix More...
 
XGB_DLL int XGDMatrixCreateFromDataIter (DataIterHandle data_handle, XGBCallbackDataIterNext *callback, const char *cache_info, DMatrixHandle *out)
 Create a DMatrix from a data iterator. More...
 
XGB_DLL int XGDMatrixCreateFromCSREx (const size_t *indptr, const unsigned *indices, const float *data, size_t nindptr, size_t nelem, size_t num_col, DMatrixHandle *out)
 create a matrix content from CSR format More...
 
XGB_DLL int XGDMatrixCreateFromCSCEx (const size_t *col_ptr, const unsigned *indices, const float *data, size_t nindptr, size_t nelem, size_t num_row, DMatrixHandle *out)
 create a matrix content from CSC format More...
 
XGB_DLL int XGDMatrixCreateFromMat (const float *data, bst_ulong nrow, bst_ulong ncol, float missing, DMatrixHandle *out)
 create matrix content from dense matrix More...
 
XGB_DLL int XGDMatrixCreateFromMat_omp (const float *data, bst_ulong nrow, bst_ulong ncol, float missing, DMatrixHandle *out, int nthread)
 create matrix content from dense matrix More...
 
XGB_DLL int XGDMatrixCreateFromDT (void **data, const char **feature_stypes, bst_ulong nrow, bst_ulong ncol, DMatrixHandle *out, int nthread)
 create matrix content from python data table More...
 
XGB_DLL int XGDMatrixSliceDMatrix (DMatrixHandle handle, const int *idxset, bst_ulong len, DMatrixHandle *out)
 create a new dmatrix from sliced content of existing matrix More...
 
XGB_DLL int XGDMatrixSliceDMatrixEx (DMatrixHandle handle, const int *idxset, bst_ulong len, DMatrixHandle *out, int allow_groups)
 create a new dmatrix from sliced content of existing matrix More...
 
XGB_DLL int XGDMatrixFree (DMatrixHandle handle)
 free space in data matrix More...
 
XGB_DLL int XGDMatrixSaveBinary (DMatrixHandle handle, const char *fname, int silent)
 load a data matrix into binary file More...
 
XGB_DLL int XGDMatrixSetFloatInfo (DMatrixHandle handle, const char *field, const float *array, bst_ulong len)
 set float vector to a content in info More...
 
XGB_DLL int XGDMatrixSetUIntInfo (DMatrixHandle handle, const char *field, const unsigned *array, bst_ulong len)
 set uint32 vector to a content in info More...
 
XGB_DLL int XGDMatrixSetGroup (DMatrixHandle handle, const unsigned *group, bst_ulong len)
 (deprecated) Use XGDMatrixSetUIntInfo instead. Set group of the training matrix More...
 
XGB_DLL int XGDMatrixGetFloatInfo (const DMatrixHandle handle, const char *field, bst_ulong *out_len, const float **out_dptr)
 get float info vector from matrix. More...
 
XGB_DLL int XGDMatrixGetUIntInfo (const DMatrixHandle handle, const char *field, bst_ulong *out_len, const unsigned **out_dptr)
 get uint32 info vector from matrix More...
 
XGB_DLL int XGDMatrixNumRow (DMatrixHandle handle, bst_ulong *out)
 get number of rows. More...
 
XGB_DLL int XGDMatrixNumCol (DMatrixHandle handle, bst_ulong *out)
 get number of columns More...
 
XGB_DLL int XGBoosterCreate (const DMatrixHandle dmats[], bst_ulong len, BoosterHandle *out)
 create xgboost learner More...
 
XGB_DLL int XGBoosterFree (BoosterHandle handle)
 free obj in handle More...
 
XGB_DLL int XGBoosterSetParam (BoosterHandle handle, const char *name, const char *value)
 set parameters More...
 
XGB_DLL int XGBoosterUpdateOneIter (BoosterHandle handle, int iter, DMatrixHandle dtrain)
 update the model in one round using dtrain More...
 
XGB_DLL int XGBoosterBoostOneIter (BoosterHandle handle, DMatrixHandle dtrain, float *grad, float *hess, bst_ulong len)
 update the model, by directly specify gradient and second order gradient, this can be used to replace UpdateOneIter, to support customized loss function More...
 
XGB_DLL int XGBoosterEvalOneIter (BoosterHandle handle, int iter, DMatrixHandle dmats[], const char *evnames[], bst_ulong len, const char **out_result)
 get evaluation statistics for xgboost More...
 
XGB_DLL int XGBoosterPredict (BoosterHandle handle, DMatrixHandle dmat, int option_mask, unsigned ntree_limit, bst_ulong *out_len, const float **out_result)
 make prediction based on dmat More...
 
XGB_DLL int XGBoosterLoadModel (BoosterHandle handle, const char *fname)
 Load model from existing file. More...
 
XGB_DLL int XGBoosterSaveModel (BoosterHandle handle, const char *fname)
 Save model into existing file. More...
 
XGB_DLL int XGBoosterLoadModelFromBuffer (BoosterHandle handle, const void *buf, bst_ulong len)
 load model from in memory buffer More...
 
XGB_DLL int XGBoosterGetModelRaw (BoosterHandle handle, bst_ulong *out_len, const char **out_dptr)
 save model into binary raw bytes, return header of the array user must copy the result out, before next xgboost call More...
 
XGB_DLL int XGBoosterDumpModel (BoosterHandle handle, const char *fmap, int with_stats, bst_ulong *out_len, const char ***out_dump_array)
 dump model, return array of strings representing model dump More...
 
XGB_DLL int XGBoosterDumpModelEx (BoosterHandle handle, const char *fmap, int with_stats, const char *format, bst_ulong *out_len, const char ***out_dump_array)
 dump model, return array of strings representing model dump More...
 
XGB_DLL int XGBoosterDumpModelWithFeatures (BoosterHandle handle, int fnum, const char **fname, const char **ftype, int with_stats, bst_ulong *out_len, const char ***out_models)
 dump model, return array of strings representing model dump More...
 
XGB_DLL int XGBoosterDumpModelExWithFeatures (BoosterHandle handle, int fnum, const char **fname, const char **ftype, int with_stats, const char *format, bst_ulong *out_len, const char ***out_models)
 dump model, return array of strings representing model dump More...
 
XGB_DLL int XGBoosterGetAttr (BoosterHandle handle, const char *key, const char **out, int *success)
 Get string attribute from Booster. More...
 
XGB_DLL int XGBoosterSetAttr (BoosterHandle handle, const char *key, const char *value)
 Set or delete string attribute. More...
 
XGB_DLL int XGBoosterGetAttrNames (BoosterHandle handle, bst_ulong *out_len, const char ***out)
 Get the names of all attribute from Booster. More...
 
XGB_DLL int XGBoosterLoadRabitCheckpoint (BoosterHandle handle, int *version)
 Initialize the booster from rabit checkpoint. This is used in distributed training API. More...
 
XGB_DLL int XGBoosterSaveRabitCheckpoint (BoosterHandle handle)
 Save the current checkpoint to rabit. More...
 

Detailed Description

C API of XGBoost, used for interfacing to other languages.

Copyright (c) 2015 by Contributors

Author
Tianqi Chen

Macro Definition Documentation

◆ XGB_DLL

#define XGB_DLL   XGB_EXTERN_C

◆ XGB_EXTERN_C

#define XGB_EXTERN_C

Typedef Documentation

◆ BoosterHandle

typedef void* BoosterHandle

handle to Booster

◆ bst_ulong

typedef uint64_t bst_ulong

◆ DataHolderHandle

typedef void* DataHolderHandle

handle to a internal data holder.

◆ DataIterHandle

typedef void* DataIterHandle

handle to a data iterator

◆ DMatrixHandle

typedef void* DMatrixHandle

handle to DMatrix

Function Documentation

◆ XGBCallbackDataIterNext()

XGB_EXTERN_C typedef int XGBCallbackDataIterNext ( DataIterHandle  data_handle,
XGBCallbackSetData set_function,
DataHolderHandle  set_function_handle 
)

The data reading callback function. The iterator will be able to give subset of batch in the data.

If there is data, the function will call set_function to set the data.

Parameters
data_handleThe handle to the callback.
set_functionThe batch returned by the iterator
set_function_handleThe handle to be passed to set function.
Returns
0 if we are reaching the end and batch is not returned.

◆ XGBCallbackSetData()

XGB_EXTERN_C typedef int XGBCallbackSetData ( DataHolderHandle  handle,
XGBoostBatchCSR  batch 
)

Callback to set the data to handle,.

Parameters
handleThe handle to the callback.
batchThe data content to be set.

◆ XGBGetLastError()

XGB_DLL const char* XGBGetLastError ( void  )

get string message of the last error

all function in this file will return 0 when success and -1 when an error occurred, XGBGetLastError can be called to retrieve the error

this function is thread safe and can be called by different thread

Returns
const char* error information

◆ XGBoosterBoostOneIter()

XGB_DLL int XGBoosterBoostOneIter ( BoosterHandle  handle,
DMatrixHandle  dtrain,
float *  grad,
float *  hess,
bst_ulong  len 
)

update the model, by directly specify gradient and second order gradient, this can be used to replace UpdateOneIter, to support customized loss function

Parameters
handlehandle
dtraintraining data
gradgradient statistics
hesssecond order gradient statistics
lenlength of grad/hess array
Returns
0 when success, -1 when failure happens

◆ XGBoosterCreate()

XGB_DLL int XGBoosterCreate ( const DMatrixHandle  dmats[],
bst_ulong  len,
BoosterHandle out 
)

create xgboost learner

Parameters
dmatsmatrices that are set to be cached
lenlength of dmats
outhandle to the result booster
Returns
0 when success, -1 when failure happens

◆ XGBoosterDumpModel()

XGB_DLL int XGBoosterDumpModel ( BoosterHandle  handle,
const char *  fmap,
int  with_stats,
bst_ulong out_len,
const char ***  out_dump_array 
)

dump model, return array of strings representing model dump

Parameters
handlehandle
fmapname to fmap can be empty string
with_statswhether to dump with statistics
out_lenlength of output array
out_dump_arraypointer to hold representing dump of each model
Returns
0 when success, -1 when failure happens

◆ XGBoosterDumpModelEx()

XGB_DLL int XGBoosterDumpModelEx ( BoosterHandle  handle,
const char *  fmap,
int  with_stats,
const char *  format,
bst_ulong out_len,
const char ***  out_dump_array 
)

dump model, return array of strings representing model dump

Parameters
handlehandle
fmapname to fmap can be empty string
with_statswhether to dump with statistics
formatthe format to dump the model in
out_lenlength of output array
out_dump_arraypointer to hold representing dump of each model
Returns
0 when success, -1 when failure happens

◆ XGBoosterDumpModelExWithFeatures()

XGB_DLL int XGBoosterDumpModelExWithFeatures ( BoosterHandle  handle,
int  fnum,
const char **  fname,
const char **  ftype,
int  with_stats,
const char *  format,
bst_ulong out_len,
const char ***  out_models 
)

dump model, return array of strings representing model dump

Parameters
handlehandle
fnumnumber of features
fnamenames of features
ftypetypes of features
with_statswhether to dump with statistics
formatthe format to dump the model in
out_lenlength of output array
out_modelspointer to hold representing dump of each model
Returns
0 when success, -1 when failure happens

◆ XGBoosterDumpModelWithFeatures()

XGB_DLL int XGBoosterDumpModelWithFeatures ( BoosterHandle  handle,
int  fnum,
const char **  fname,
const char **  ftype,
int  with_stats,
bst_ulong out_len,
const char ***  out_models 
)

dump model, return array of strings representing model dump

Parameters
handlehandle
fnumnumber of features
fnamenames of features
ftypetypes of features
with_statswhether to dump with statistics
out_lenlength of output array
out_modelspointer to hold representing dump of each model
Returns
0 when success, -1 when failure happens

◆ XGBoosterEvalOneIter()

XGB_DLL int XGBoosterEvalOneIter ( BoosterHandle  handle,
int  iter,
DMatrixHandle  dmats[],
const char *  evnames[],
bst_ulong  len,
const char **  out_result 
)

get evaluation statistics for xgboost

Parameters
handlehandle
itercurrent iteration rounds
dmatspointers to data to be evaluated
evnamespointers to names of each data
lenlength of dmats
out_resultthe string containing evaluation statistics
Returns
0 when success, -1 when failure happens

◆ XGBoosterFree()

XGB_DLL int XGBoosterFree ( BoosterHandle  handle)

free obj in handle

Parameters
handlehandle to be freed
Returns
0 when success, -1 when failure happens

◆ XGBoosterGetAttr()

XGB_DLL int XGBoosterGetAttr ( BoosterHandle  handle,
const char *  key,
const char **  out,
int *  success 
)

Get string attribute from Booster.

Parameters
handlehandle
keyThe key of the attribute.
outThe result attribute, can be NULL if the attribute do not exist.
successWhether the result is contained in out.
Returns
0 when success, -1 when failure happens

◆ XGBoosterGetAttrNames()

XGB_DLL int XGBoosterGetAttrNames ( BoosterHandle  handle,
bst_ulong out_len,
const char ***  out 
)

Get the names of all attribute from Booster.

Parameters
handlehandle
out_lenthe argument to hold the output length
outpointer to hold the output attribute stings
Returns
0 when success, -1 when failure happens

◆ XGBoosterGetModelRaw()

XGB_DLL int XGBoosterGetModelRaw ( BoosterHandle  handle,
bst_ulong out_len,
const char **  out_dptr 
)

save model into binary raw bytes, return header of the array user must copy the result out, before next xgboost call

Parameters
handlehandle
out_lenthe argument to hold the output length
out_dptrthe argument to hold the output data pointer
Returns
0 when success, -1 when failure happens

◆ XGBoosterLoadModel()

XGB_DLL int XGBoosterLoadModel ( BoosterHandle  handle,
const char *  fname 
)

Load model from existing file.

Parameters
handlehandle
fnamefile name
Returns
0 when success, -1 when failure happens

◆ XGBoosterLoadModelFromBuffer()

XGB_DLL int XGBoosterLoadModelFromBuffer ( BoosterHandle  handle,
const void *  buf,
bst_ulong  len 
)

load model from in memory buffer

Parameters
handlehandle
bufpointer to the buffer
lenthe length of the buffer
Returns
0 when success, -1 when failure happens

◆ XGBoosterLoadRabitCheckpoint()

XGB_DLL int XGBoosterLoadRabitCheckpoint ( BoosterHandle  handle,
int *  version 
)

Initialize the booster from rabit checkpoint. This is used in distributed training API.

Parameters
handlehandle
versionThe output version of the model.
Returns
0 when success, -1 when failure happens

◆ XGBoosterPredict()

XGB_DLL int XGBoosterPredict ( BoosterHandle  handle,
DMatrixHandle  dmat,
int  option_mask,
unsigned  ntree_limit,
bst_ulong out_len,
const float **  out_result 
)

make prediction based on dmat

Parameters
handlehandle
dmatdata matrix
option_maskbit-mask of options taken in prediction, possible values 0:normal prediction 1:output margin instead of transformed value 2:output leaf index of trees instead of leaf value, note leaf index is unique per tree 4:output feature contributions to individual predictions
ntree_limitlimit number of trees used for prediction, this is only valid for boosted trees when the parameter is set to 0, we will use all the trees
out_lenused to store length of returning result
out_resultused to set a pointer to array
Returns
0 when success, -1 when failure happens

◆ XGBoosterSaveModel()

XGB_DLL int XGBoosterSaveModel ( BoosterHandle  handle,
const char *  fname 
)

Save model into existing file.

Parameters
handlehandle
fnamefile name
Returns
0 when success, -1 when failure happens

◆ XGBoosterSaveRabitCheckpoint()

XGB_DLL int XGBoosterSaveRabitCheckpoint ( BoosterHandle  handle)

Save the current checkpoint to rabit.

Parameters
handlehandle
Returns
0 when success, -1 when failure happens

◆ XGBoosterSetAttr()

XGB_DLL int XGBoosterSetAttr ( BoosterHandle  handle,
const char *  key,
const char *  value 
)

Set or delete string attribute.

Parameters
handlehandle
keyThe key of the attribute.
valueThe value to be saved. If nullptr, the attribute would be deleted.
Returns
0 when success, -1 when failure happens

◆ XGBoosterSetParam()

XGB_DLL int XGBoosterSetParam ( BoosterHandle  handle,
const char *  name,
const char *  value 
)

set parameters

Parameters
handlehandle
nameparameter name
valuevalue of parameter
Returns
0 when success, -1 when failure happens

◆ XGBoosterUpdateOneIter()

XGB_DLL int XGBoosterUpdateOneIter ( BoosterHandle  handle,
int  iter,
DMatrixHandle  dtrain 
)

update the model in one round using dtrain

Parameters
handlehandle
itercurrent iteration rounds
dtraintraining data
Returns
0 when success, -1 when failure happens

◆ XGBoostVersion()

XGB_DLL void XGBoostVersion ( int *  major,
int *  minor,
int *  patch 
)

Return the version of the XGBoost library being currently used.

The output variable is only written if it's not NULL.

Parameters
majorStore the major version number
minorStore the minor version number
patchStore the patch (revision) number

◆ XGBRegisterLogCallback()

XGB_DLL int XGBRegisterLogCallback ( void(*)(const char *)  callback)

register callback function for LOG(INFO) messages – helpful messages that are not errors. Note: this function can be called by multiple threads. The callback function will run on the thread that registered it

Returns
0 for success, -1 for failure

◆ XGDMatrixCreateFromCSCEx()

XGB_DLL int XGDMatrixCreateFromCSCEx ( const size_t *  col_ptr,
const unsigned *  indices,
const float *  data,
size_t  nindptr,
size_t  nelem,
size_t  num_row,
DMatrixHandle out 
)

create a matrix content from CSC format

Parameters
col_ptrpointer to col headers
indicesfindex
datafvalue
nindptrnumber of rows in the matrix + 1
nelemnumber of nonzero elements in the matrix
num_rownumber of rows; when it's set to 0, then guess from data
outcreated dmatrix
Returns
0 when success, -1 when failure happens

◆ XGDMatrixCreateFromCSREx()

XGB_DLL int XGDMatrixCreateFromCSREx ( const size_t *  indptr,
const unsigned *  indices,
const float *  data,
size_t  nindptr,
size_t  nelem,
size_t  num_col,
DMatrixHandle out 
)

create a matrix content from CSR format

Parameters
indptrpointer to row headers
indicesfindex
datafvalue
nindptrnumber of rows in the matrix + 1
nelemnumber of nonzero elements in the matrix
num_colnumber of columns; when it's set to 0, then guess from data
outcreated dmatrix
Returns
0 when success, -1 when failure happens

◆ XGDMatrixCreateFromDataIter()

XGB_DLL int XGDMatrixCreateFromDataIter ( DataIterHandle  data_handle,
XGBCallbackDataIterNext callback,
const char *  cache_info,
DMatrixHandle out 
)

Create a DMatrix from a data iterator.

Parameters
data_handleThe handle to the data.
callbackThe callback to get the data.
cache_infoAdditional information about cache file, can be null.
outThe created DMatrix
Returns
0 when success, -1 when failure happens.

◆ XGDMatrixCreateFromDT()

XGB_DLL int XGDMatrixCreateFromDT ( void **  data,
const char **  feature_stypes,
bst_ulong  nrow,
bst_ulong  ncol,
DMatrixHandle out,
int  nthread 
)

create matrix content from python data table

Parameters
datapointer to pointer to column data
feature_stypespointer to strings
nrownumber of rows
ncolnumber columns
outcreated dmatrix
nthreadnumber of threads (up to maximum cores available, if <=0 use all cores)
Returns
0 when success, -1 when failure happens

◆ XGDMatrixCreateFromFile()

XGB_DLL int XGDMatrixCreateFromFile ( const char *  fname,
int  silent,
DMatrixHandle out 
)

load a data matrix

Parameters
fnamethe name of the file
silentwhether print messages during loading
outa loaded data matrix
Returns
0 when success, -1 when failure happens

◆ XGDMatrixCreateFromMat()

XGB_DLL int XGDMatrixCreateFromMat ( const float *  data,
bst_ulong  nrow,
bst_ulong  ncol,
float  missing,
DMatrixHandle out 
)

create matrix content from dense matrix

Parameters
datapointer to the data space
nrownumber of rows
ncolnumber columns
missingwhich value to represent missing value
outcreated dmatrix
Returns
0 when success, -1 when failure happens

◆ XGDMatrixCreateFromMat_omp()

XGB_DLL int XGDMatrixCreateFromMat_omp ( const float *  data,
bst_ulong  nrow,
bst_ulong  ncol,
float  missing,
DMatrixHandle out,
int  nthread 
)

create matrix content from dense matrix

Parameters
datapointer to the data space
nrownumber of rows
ncolnumber columns
missingwhich value to represent missing value
outcreated dmatrix
nthreadnumber of threads (up to maximum cores available, if <=0 use all cores)
Returns
0 when success, -1 when failure happens

◆ XGDMatrixFree()

XGB_DLL int XGDMatrixFree ( DMatrixHandle  handle)

free space in data matrix

Returns
0 when success, -1 when failure happens

◆ XGDMatrixGetFloatInfo()

XGB_DLL int XGDMatrixGetFloatInfo ( const DMatrixHandle  handle,
const char *  field,
bst_ulong out_len,
const float **  out_dptr 
)

get float info vector from matrix.

Parameters
handlea instance of data matrix
fieldfield name
out_lenused to set result length
out_dptrpointer to the result
Returns
0 when success, -1 when failure happens

◆ XGDMatrixGetUIntInfo()

XGB_DLL int XGDMatrixGetUIntInfo ( const DMatrixHandle  handle,
const char *  field,
bst_ulong out_len,
const unsigned **  out_dptr 
)

get uint32 info vector from matrix

Parameters
handlea instance of data matrix
fieldfield name
out_lenThe length of the field.
out_dptrpointer to the result
Returns
0 when success, -1 when failure happens

◆ XGDMatrixNumCol()

XGB_DLL int XGDMatrixNumCol ( DMatrixHandle  handle,
bst_ulong out 
)

get number of columns

Parameters
handlethe handle to the DMatrix
outThe output of number of columns
Returns
0 when success, -1 when failure happens

◆ XGDMatrixNumRow()

XGB_DLL int XGDMatrixNumRow ( DMatrixHandle  handle,
bst_ulong out 
)

get number of rows.

Parameters
handlethe handle to the DMatrix
outThe address to hold number of rows.
Returns
0 when success, -1 when failure happens

◆ XGDMatrixSaveBinary()

XGB_DLL int XGDMatrixSaveBinary ( DMatrixHandle  handle,
const char *  fname,
int  silent 
)

load a data matrix into binary file

Parameters
handlea instance of data matrix
fnamefile name
silentprint statistics when saving
Returns
0 when success, -1 when failure happens

◆ XGDMatrixSetFloatInfo()

XGB_DLL int XGDMatrixSetFloatInfo ( DMatrixHandle  handle,
const char *  field,
const float *  array,
bst_ulong  len 
)

set float vector to a content in info

Parameters
handlea instance of data matrix
fieldfield name, can be label, weight
arraypointer to float vector
lenlength of array
Returns
0 when success, -1 when failure happens

◆ XGDMatrixSetGroup()

XGB_DLL int XGDMatrixSetGroup ( DMatrixHandle  handle,
const unsigned *  group,
bst_ulong  len 
)

(deprecated) Use XGDMatrixSetUIntInfo instead. Set group of the training matrix

Parameters
handlea instance of data matrix
grouppointer to group size
lenlength of array
Returns
0 when success, -1 when failure happens

◆ XGDMatrixSetUIntInfo()

XGB_DLL int XGDMatrixSetUIntInfo ( DMatrixHandle  handle,
const char *  field,
const unsigned *  array,
bst_ulong  len 
)

set uint32 vector to a content in info

Parameters
handlea instance of data matrix
fieldfield name
arraypointer to unsigned int vector
lenlength of array
Returns
0 when success, -1 when failure happens

◆ XGDMatrixSliceDMatrix()

XGB_DLL int XGDMatrixSliceDMatrix ( DMatrixHandle  handle,
const int *  idxset,
bst_ulong  len,
DMatrixHandle out 
)

create a new dmatrix from sliced content of existing matrix

Parameters
handleinstance of data matrix to be sliced
idxsetindex set
lenlength of index set
outa sliced new matrix
Returns
0 when success, -1 when failure happens

◆ XGDMatrixSliceDMatrixEx()

XGB_DLL int XGDMatrixSliceDMatrixEx ( DMatrixHandle  handle,
const int *  idxset,
bst_ulong  len,
DMatrixHandle out,
int  allow_groups 
)

create a new dmatrix from sliced content of existing matrix

Parameters
handleinstance of data matrix to be sliced
idxsetindex set
lenlength of index set
outa sliced new matrix
allow_groupsallow slicing of an array with groups
Returns
0 when success, -1 when failure happens