xgboost
c_api.h
Go to the documentation of this file.
1 
7 #ifndef XGBOOST_C_API_H_
8 #define XGBOOST_C_API_H_
9 
10 #ifdef __cplusplus
11 #define XGB_EXTERN_C extern "C"
12 #include <cstddef>
13 #include <cstdio>
14 #include <cstdint>
15 #else
16 #define XGB_EXTERN_C
17 #include <stddef.h>
18 #include <stdio.h>
19 #include <stdint.h>
20 #endif // __cplusplus
21 
22 #if defined(_MSC_VER) || defined(_WIN32)
23 #define XGB_DLL XGB_EXTERN_C __declspec(dllexport)
24 #else
25 #define XGB_DLL XGB_EXTERN_C __attribute__ ((visibility ("default")))
26 #endif // defined(_MSC_VER) || defined(_WIN32)
27 
28 // manually define unsigned long
29 typedef uint64_t bst_ulong; // NOLINT(*)
30 
50 typedef void *DMatrixHandle; // NOLINT(*)
52 typedef void *BoosterHandle; // NOLINT(*)
53 
63 XGB_DLL void XGBoostVersion(int* major, int* minor, int* patch);
64 
72 XGB_DLL int XGBuildInfo(char const **out);
73 
84 XGB_DLL const char *XGBGetLastError();
85 
93 XGB_DLL int XGBRegisterLogCallback(void (*callback)(const char*));
94 
103 XGB_DLL int XGBSetGlobalConfig(char const *config);
104 
110 XGB_DLL int XGBGetGlobalConfig(char const **out_config);
111 
136 XGB_DLL int XGDMatrixCreateFromFile(const char *fname, int silent, DMatrixHandle *out);
137 
153 XGB_DLL int XGDMatrixCreateFromURI(char const *config, DMatrixHandle *out);
154 
155 
161 XGB_DLL int XGDMatrixCreateFromCSREx(const size_t *indptr, const unsigned *indices,
162  const float *data, size_t nindptr, size_t nelem,
163  size_t num_col, DMatrixHandle *out);
164 
180 XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data,
181  bst_ulong ncol, char const *config, DMatrixHandle *out);
182 
192 XGB_DLL int XGDMatrixCreateFromDense(char const *data, char const *config, DMatrixHandle *out);
193 
206 XGB_DLL int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char const *data,
207  bst_ulong nrow, char const *config, DMatrixHandle *out);
208 
214 XGB_DLL int XGDMatrixCreateFromCSCEx(const size_t *col_ptr, const unsigned *indices,
215  const float *data, size_t nindptr, size_t nelem,
216  size_t num_row, DMatrixHandle *out);
217 
227 XGB_DLL int XGDMatrixCreateFromMat(const float *data,
228  bst_ulong nrow,
229  bst_ulong ncol,
230  float missing,
231  DMatrixHandle *out);
242 XGB_DLL int XGDMatrixCreateFromMat_omp(const float *data, // NOLINT
243  bst_ulong nrow, bst_ulong ncol,
244  float missing, DMatrixHandle *out,
245  int nthread);
257  const char ** feature_stypes,
258  bst_ulong nrow,
259  bst_ulong ncol,
260  DMatrixHandle* out,
261  int nthread);
262 
272 XGB_DLL int XGDMatrixCreateFromCudaColumnar(char const *data, char const *config,
273  DMatrixHandle *out);
274 
284 XGB_DLL int XGDMatrixCreateFromCudaArrayInterface(char const *data, char const *config,
285  DMatrixHandle *out);
286 
332 /* ==== First set of callback functions, used exclusively by JVM packages. ==== */
333 
335 typedef void *DataIterHandle; // NOLINT(*)
337 typedef void *DataHolderHandle; // NOLINT(*)
338 
339 
341 typedef struct { // NOLINT(*)
343  size_t size;
344  /* \brief number of columns in the minibatch. */
345  size_t columns;
347 #ifdef __APPLE__
348  /* Necessary as Java on MacOS defines jlong as long int
349  * and gcc defines int64_t as long long int. */
350  long* offset; // NOLINT(*)
351 #else
352  int64_t* offset; // NOLINT(*)
353 #endif // __APPLE__
355  float* label;
357  float* weight;
359  int* index;
361  float* value;
363 
369 XGB_EXTERN_C typedef int XGBCallbackSetData( // NOLINT(*)
370  DataHolderHandle handle, XGBoostBatchCSR batch);
371 
383 XGB_EXTERN_C typedef int XGBCallbackDataIterNext( // NOLINT(*)
384  DataIterHandle data_handle, XGBCallbackSetData *set_function,
385  DataHolderHandle set_function_handle);
386 
396  DataIterHandle data_handle,
397  XGBCallbackDataIterNext* callback,
398  const char* cache_info,
399  DMatrixHandle *out);
400 
414 
422 XGB_EXTERN_C typedef int XGDMatrixCallbackNext(DataIterHandle iter); // NOLINT(*)
423 
427 XGB_EXTERN_C typedef void DataIterResetCallback(DataIterHandle handle); // NOLINT(*)
428 
429 
455  char const *config, DMatrixHandle *out);
488  XGDMatrixCallbackNext *next, char const *config,
489  DMatrixHandle *out);
490 
497  DataIterResetCallback *reset,
498  XGDMatrixCallbackNext *next, float missing,
499  int nthread, int max_bin, DMatrixHandle *out);
500 
510 XGB_DLL int
512  const char *c_interface_str);
513 
524  const char *c_interface_str);
525 
536  char const *c_interface_str);
537 
549 XGB_DLL int XGProxyDMatrixSetDataCSR(DMatrixHandle handle, char const *indptr,
550  char const *indices, char const *data,
551  bst_ulong ncol);
552  // End of Streaming
554 
555 XGB_DLL int XGImportArrowRecordBatch(DataIterHandle data_handle, void *ptr_array, void *ptr_schema);
556 
571  DMatrixHandle *out);
572 
582  const int *idxset,
583  bst_ulong len,
584  DMatrixHandle *out);
595  const int *idxset,
596  bst_ulong len,
597  DMatrixHandle *out,
598  int allow_groups);
616  const char *fname, int silent);
617 
626  char const* field,
627  char const* c_interface_str);
628 
638  const char *field,
639  const float *array,
640  bst_ulong len);
650  const char *field,
651  const unsigned *array,
652  bst_ulong len);
653 
680 XGB_DLL int XGDMatrixSetStrFeatureInfo(DMatrixHandle handle, const char *field,
681  const char **features,
682  const bst_ulong size);
683 
719 XGB_DLL int XGDMatrixGetStrFeatureInfo(DMatrixHandle handle, const char *field,
720  bst_ulong *size,
721  const char ***out_features);
722 
746 XGB_DLL int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field,
747  void const *data, bst_ulong size, int type);
748 
757  const unsigned *group,
758  bst_ulong len);
759 
768 XGB_DLL int XGDMatrixGetFloatInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
769  const float **out_dptr);
783  const char *field,
784  bst_ulong* out_len,
785  const unsigned **out_dptr);
793  bst_ulong *out);
801  bst_ulong *out);
802 
812 
833 XGB_DLL int XGDMatrixGetDataAsCSR(DMatrixHandle const handle, char const *config,
834  bst_ulong *out_indptr, unsigned *out_indices, float *out_data);
835 
851 XGB_DLL int XGDMatrixGetQuantileCut(DMatrixHandle const handle, char const *config,
852  char const **out_indptr, char const **out_data);
853  // End of DMatrix
855 
898 XGB_DLL int XGBoosterSlice(BoosterHandle handle, int begin_layer,
899  int end_layer, int step,
900  BoosterHandle *out);
901 
910 
919  const char *name,
920  const char *value);
959  DMatrixHandle dtrain,
960  float *grad,
961  float *hess,
962  bst_ulong len);
974  const char *evnames[], bst_ulong len, const char **out_result);
1015  DMatrixHandle dmat,
1016  int option_mask,
1017  unsigned ntree_limit,
1018  int training,
1019  bst_ulong *out_len,
1020  const float **out_result);
1021 
1081  char const *config, bst_ulong const **out_shape,
1082  bst_ulong *out_dim, float const **out_result);
1107 XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *values, char const *config,
1108  DMatrixHandle m, bst_ulong const **out_shape,
1109  bst_ulong *out_dim, const float **out_result);
1137 XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
1138  char const *values, bst_ulong ncol, char const *config,
1139  DMatrixHandle m, bst_ulong const **out_shape,
1140  bst_ulong *out_dim, const float **out_result);
1141 
1161 XGB_DLL int XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values,
1162  char const *config, DMatrixHandle m,
1163  bst_ulong const **out_shape, bst_ulong *out_dim,
1164  const float **out_result);
1165 
1186  char const *config, DMatrixHandle m,
1187  bst_ulong const **out_shape, bst_ulong *out_dim,
1188  const float **out_result);
1189  // End of Prediction
1191 
1192 
1228  const char *fname);
1237  const char *fname);
1247  const void *buf,
1248  bst_ulong len);
1249 
1269 XGB_DLL int XGBoosterSaveModelToBuffer(BoosterHandle handle, char const *config, bst_ulong *out_len,
1270  char const **out_dptr);
1271 
1279  const char **out_dptr);
1280 
1291  const char **out_dptr);
1302  const void *buf, bst_ulong len);
1303 
1312  int* version);
1313 
1320 
1321 
1335  char const **out_str);
1345 XGB_DLL int XGBoosterLoadJsonConfig(BoosterHandle handle, char const *config); // End of Serialization
1347 
1358  const char *fmap,
1359  int with_stats,
1360  bst_ulong *out_len,
1361  const char ***out_dump_array);
1362 
1374  const char *fmap,
1375  int with_stats,
1376  const char *format,
1377  bst_ulong *out_len,
1378  const char ***out_dump_array);
1379 
1392  int fnum,
1393  const char **fname,
1394  const char **ftype,
1395  int with_stats,
1396  bst_ulong *out_len,
1397  const char ***out_models);
1398 
1412  int fnum,
1413  const char **fname,
1414  const char **ftype,
1415  int with_stats,
1416  const char *format,
1417  bst_ulong *out_len,
1418  const char ***out_models);
1419 
1429  const char* key,
1430  const char** out,
1431  int *success);
1442  const char* key,
1443  const char* value);
1452  bst_ulong* out_len,
1453  const char*** out);
1454 
1470 XGB_DLL int XGBoosterSetStrFeatureInfo(BoosterHandle handle, const char *field,
1471  const char **features,
1472  const bst_ulong size);
1473 
1493 XGB_DLL int XGBoosterGetStrFeatureInfo(BoosterHandle handle, const char *field,
1494  bst_ulong *len,
1495  const char ***out_features);
1496 
1522 XGB_DLL int XGBoosterFeatureScore(BoosterHandle handle, const char *config,
1523  bst_ulong *out_n_features, char const ***out_features,
1524  bst_ulong *out_dim, bst_ulong const **out_shape,
1525  float const **out_scores); // End of Booster
1527 
1584 XGB_DLL int XGCommunicatorInit(char const* config);
1585 
1594 
1601 
1608 
1615 
1625 XGB_DLL int XGCommunicatorPrint(char const *message);
1626 
1633 XGB_DLL int XGCommunicatorGetProcessorName(const char** name_str);
1634 
1649 XGB_DLL int XGCommunicatorBroadcast(void *send_receive_buffer, size_t size, int root);
1650 
1668 XGB_DLL int XGCommunicatorAllreduce(void *send_receive_buffer, size_t count, int data_type, int op);
1669  // End of Collective
1671 #endif // XGBOOST_C_API_H_
#define XGB_EXTERN_C
Definition: c_api.h:16
#define XGB_DLL
Definition: c_api.h:25
uint64_t bst_ulong
Definition: c_api.h:29
int XGBoosterBoostedRounds(BoosterHandle handle, int *out)
Get number of boosted rounds from gradient booster. When process_type is update, this number might dr...
int XGBoosterSetAttr(BoosterHandle handle, const char *key, const char *value)
Set or delete string attribute.
int XGBoosterFeatureScore(BoosterHandle handle, const char *config, bst_ulong *out_n_features, char const ***out_features, bst_ulong *out_dim, bst_ulong const **out_shape, float const **out_scores)
Calculate feature scores for tree models. When used on linear model, only the weight importance type ...
int XGBoosterGetNumFeature(BoosterHandle handle, bst_ulong *out)
get number of features
int XGBoosterFree(BoosterHandle handle)
free obj in handle
int XGBoosterGetAttr(BoosterHandle handle, const char *key, const char **out, int *success)
Get string attribute from Booster.
int XGBoosterSetStrFeatureInfo(BoosterHandle handle, const char *field, const char **features, const bst_ulong size)
Set string encoded feature info in Booster, similar to the feature info in DMatrix.
int XGBoosterSlice(BoosterHandle handle, int begin_layer, int end_layer, int step, BoosterHandle *out)
Slice a model using boosting index. The slice m:n indicates taking all trees that were fit during the...
int XGBoosterGetStrFeatureInfo(BoosterHandle handle, const char *field, bst_ulong *len, const char ***out_features)
Get string encoded feature info from Booster, similar to feature info in DMatrix.
int XGBoosterEvalOneIter(BoosterHandle handle, int iter, DMatrixHandle dmats[], const char *evnames[], bst_ulong len, const char **out_result)
get evaluation statistics for xgboost
int XGBoosterUpdateOneIter(BoosterHandle handle, int iter, DMatrixHandle dtrain)
update the model in one round using dtrain
int XGBoosterSetParam(BoosterHandle handle, const char *name, const char *value)
set parameters
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
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
int XGBoosterGetAttrNames(BoosterHandle handle, bst_ulong *out_len, const char ***out)
Get the names of all attribute from Booster.
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...
int XGBoosterCreate(const DMatrixHandle dmats[], bst_ulong len, BoosterHandle *out)
create xgboost learner
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
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
int XGCommunicatorAllreduce(void *send_receive_buffer, size_t count, int data_type, int op)
Perform in-place allreduce. This function is NOT thread-safe.
int XGCommunicatorGetWorldSize(void)
Get total number of processes.
int XGCommunicatorBroadcast(void *send_receive_buffer, size_t size, int root)
Broadcast a memory region to all others from root. This function is NOT thread-safe.
int XGCommunicatorGetRank(void)
Get rank of current process.
int XGCommunicatorPrint(char const *message)
Print the message to the communicator.
int XGCommunicatorInit(char const *config)
Initialize the collective communicator.
int XGCommunicatorGetProcessorName(const char **name_str)
Get the name of the processor.
int XGCommunicatorFinalize(void)
Finalize the collective communicator.
int XGCommunicatorIsDistributed(void)
Get if the communicator is distributed.
int XGDMatrixCreateFromArrowCallback(XGDMatrixCallbackNext *next, char const *config, DMatrixHandle *out)
Construct DMatrix from arrow using callbacks. Arrow related C API is not stable and subject to change...
int XGDMatrixSetUIntInfo(DMatrixHandle handle, const char *field, const unsigned *array, bst_ulong len)
set uint32 vector to a content in info
int XGDMatrixSetStrFeatureInfo(DMatrixHandle handle, const char *field, const char **features, const bst_ulong size)
Set string encoded information of all features.
int XGDMatrixFree(DMatrixHandle handle)
free space in data matrix
int XGDMatrixSetInfoFromInterface(DMatrixHandle handle, char const *field, char const *c_interface_str)
Set content in array interface to a content in info.
int XGDMatrixCreateFromCudaColumnar(char const *data, char const *config, DMatrixHandle *out)
Create DMatrix from CUDA columnar format. (cuDF)
int XGDMatrixCreateFromDense(char const *data, char const *config, DMatrixHandle *out)
Create a matrix from dense array.
int XGDMatrixSaveBinary(DMatrixHandle handle, const char *fname, int silent)
load a data matrix into binary file
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
int XGDMatrixSliceDMatrix(DMatrixHandle handle, const int *idxset, bst_ulong len, DMatrixHandle *out)
create a new dmatrix from sliced content of existing matrix
int XGDMatrixNumRow(DMatrixHandle handle, bst_ulong *out)
get number of rows.
int XGImportArrowRecordBatch(DataIterHandle data_handle, void *ptr_array, void *ptr_schema)
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
int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data, bst_ulong ncol, char const *config, DMatrixHandle *out)
Create a matrix from CSR matrix.
int XGDMatrixCreateFromFile(const char *fname, int silent, DMatrixHandle *out)
load a data matrix
int XGDMatrixSetGroup(DMatrixHandle handle, const unsigned *group, bst_ulong len)
(deprecated) Use XGDMatrixSetUIntInfo instead. Set group of the training matrix
int XGDMatrixCreateFromCudaArrayInterface(char const *data, char const *config, DMatrixHandle *out)
Create DMatrix from CUDA array.
int XGDMatrixNumNonMissing(DMatrixHandle handle, bst_ulong *out)
Get number of valid values from DMatrix.
int XGDMatrixGetDataAsCSR(DMatrixHandle const handle, char const *config, bst_ulong *out_indptr, unsigned *out_indices, float *out_data)
Get the predictors from DMatrix as CSR matrix for testing. If this is a quantized DMatrix,...
int XGDMatrixGetStrFeatureInfo(DMatrixHandle handle, const char *field, bst_ulong *size, const char ***out_features)
Get string encoded information of all features.
int XGDMatrixCreateFromMat_omp(const float *data, bst_ulong nrow, bst_ulong ncol, float missing, DMatrixHandle *out, int nthread)
create matrix content from dense matrix
int XGDMatrixGetUIntInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len, const unsigned **out_dptr)
get uint32 info vector from matrix
int XGDMatrixNumCol(DMatrixHandle handle, bst_ulong *out)
get number of columns
int XGDMatrixSetFloatInfo(DMatrixHandle handle, const char *field, const float *array, bst_ulong len)
set float vector to a content in info
int XGDMatrixGetQuantileCut(DMatrixHandle const handle, char const *config, char const **out_indptr, char const **out_data)
Export the quantile cuts used for training histogram-based models like hist and approx....
int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field, void const *data, bst_ulong size, int type)
Set meta info from dense matrix. Valid field names are:
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
int XGDMatrixCreateFromURI(char const *config, DMatrixHandle *out)
load a data matrix
int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char const *data, bst_ulong nrow, char const *config, DMatrixHandle *out)
Create a matrix from a CSC matrix.
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
int XGDMatrixCreateFromMat(const float *data, bst_ulong nrow, bst_ulong ncol, float missing, DMatrixHandle *out)
create matrix content from dense matrix
int XGDMatrixGetFloatInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len, const float **out_dptr)
get float info vector from matrix.
int XGBGetGlobalConfig(char const **out_config)
Get current global configuration (collection of parameters that apply globally).
void * BoosterHandle
handle to Booster
Definition: c_api.h:52
const char * XGBGetLastError()
get string message of the last error
int XGBSetGlobalConfig(char const *config)
Set global configuration (collection of parameters that apply globally). This function accepts the li...
int XGBuildInfo(char const **out)
Get compile information of shared library.
void * DMatrixHandle
handle to DMatrix
Definition: c_api.h:50
int XGBRegisterLogCallback(void(*callback)(const char *))
register callback function for LOG(INFO) messages – helpful messages that are not errors....
void XGBoostVersion(int *major, int *minor, int *patch)
Return the version of the XGBoost library being currently used.
int XGBoosterPredictFromDense(BoosterHandle handle, char const *values, char const *config, DMatrixHandle m, bst_ulong const **out_shape, bst_ulong *out_dim, const float **out_result)
Inplace prediction from CPU dense matrix.
int XGBoosterPredict(BoosterHandle handle, DMatrixHandle dmat, int option_mask, unsigned ntree_limit, int training, bst_ulong *out_len, const float **out_result)
make prediction based on dmat (deprecated, use XGBoosterPredictFromDMatrix instead)
int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices, char const *values, bst_ulong ncol, char const *config, DMatrixHandle m, bst_ulong const **out_shape, bst_ulong *out_dim, const float **out_result)
Inplace prediction from CPU CSR matrix.
int XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values, char const *config, DMatrixHandle m, bst_ulong const **out_shape, bst_ulong *out_dim, const float **out_result)
Inplace prediction from CUDA Dense matrix (cupy in Python).
int XGBoosterPredictFromDMatrix(BoosterHandle handle, DMatrixHandle dmat, char const *config, bst_ulong const **out_shape, bst_ulong *out_dim, float const **out_result)
Make prediction from DMatrix, replacing XGBoosterPredict.
int XGBoosterPredictFromCudaColumnar(BoosterHandle handle, char const *values, char const *config, DMatrixHandle m, bst_ulong const **out_shape, bst_ulong *out_dim, const float **out_result)
Inplace prediction from CUDA dense dataframe (cuDF in Python).
int XGBoosterSaveRabitCheckpoint(BoosterHandle handle)
Save the current checkpoint to rabit.
int XGBoosterLoadModelFromBuffer(BoosterHandle handle, const void *buf, bst_ulong len)
load model from in memory buffer
int XGBoosterSaveModel(BoosterHandle handle, const char *fname)
Save model into existing file.
int XGBoosterLoadRabitCheckpoint(BoosterHandle handle, int *version)
Initialize the booster from rabit checkpoint. This is used in distributed training API.
int XGBoosterLoadJsonConfig(BoosterHandle handle, char const *config)
Load XGBoost's internal configuration from a JSON document. Currently the support is experimental,...
int XGBoosterUnserializeFromBuffer(BoosterHandle handle, const void *buf, bst_ulong len)
Memory snapshot based serialization method. Loads the buffer returned from XGBoosterSerializeToBuffer...
int XGBoosterSaveModelToBuffer(BoosterHandle handle, char const *config, bst_ulong *out_len, char const **out_dptr)
Save model into raw bytes, return header of the array. User must copy the result out,...
int XGBoosterLoadModel(BoosterHandle handle, const char *fname)
Load model from existing file.
int XGBoosterSaveJsonConfig(BoosterHandle handle, bst_ulong *out_len, char const **out_str)
Save XGBoost's internal configuration into a JSON document. Currently the support is experimental,...
int XGBoosterSerializeToBuffer(BoosterHandle handle, bst_ulong *out_len, const char **out_dptr)
Memory snapshot based serialization method. Saves everything states into buffer.
int XGBoosterGetModelRaw(BoosterHandle handle, bst_ulong *out_len, const char **out_dptr)
Save booster to a buffer with in binary format.
void * DataHolderHandle
handle to a internal data holder.
Definition: c_api.h:337
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.
Definition: c_api.h:383
int XGProxyDMatrixSetDataCSR(DMatrixHandle handle, char const *indptr, char const *indices, char const *data, bst_ulong ncol)
Set data on a DMatrix proxy.
int XGBCallbackSetData(DataHolderHandle handle, XGBoostBatchCSR batch)
Callback to set the data to handle,.
Definition: c_api.h:369
int XGDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, char const *config, DMatrixHandle *out)
Create an external memory DMatrix with data iterator.
int XGProxyDMatrixSetDataDense(DMatrixHandle handle, char const *c_interface_str)
Set data on a DMatrix proxy.
int XGDeviceQuantileDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, float missing, int nthread, int max_bin, DMatrixHandle *out)
Create a Device Quantile DMatrix with data iterator.
int XGProxyDMatrixCreate(DMatrixHandle *out)
Create a DMatrix proxy for setting data, can be free by XGDMatrixFree.
int XGDMatrixCallbackNext(DataIterHandle iter)
Callback function prototype for getting next batch of data.
Definition: c_api.h:422
void * DataIterHandle
handle to a external data iterator
Definition: c_api.h:335
int XGQuantileDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy, DataIterHandle ref, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, char const *config, DMatrixHandle *out)
Create a Quantile DMatrix with data iterator.
int XGDMatrixCreateFromDataIter(DataIterHandle data_handle, XGBCallbackDataIterNext *callback, const char *cache_info, DMatrixHandle *out)
Create a DMatrix from a data iterator.
void DataIterResetCallback(DataIterHandle handle)
Callback function prototype for resetting external iterator.
Definition: c_api.h:427
int XGProxyDMatrixSetDataCudaColumnar(DMatrixHandle handle, const char *c_interface_str)
Set data on a DMatrix proxy.
int XGProxyDMatrixSetDataCudaArrayInterface(DMatrixHandle handle, const char *c_interface_str)
Set data on a DMatrix proxy.
Mini batch used in XGBoost Data Iteration.
Definition: c_api.h:341
int64_t * offset
row pointer to the rows in the data
Definition: c_api.h:352
int * index
feature index
Definition: c_api.h:359
float * value
feature values
Definition: c_api.h:361
size_t columns
Definition: c_api.h:345
float * weight
weight of each instance, can be NULL
Definition: c_api.h:357
size_t size
number of rows in the minibatch
Definition: c_api.h:343