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 
150 XGB_DLL int XGDMatrixCreateFromURI(char const *config, DMatrixHandle *out);
151 
152 
158 XGB_DLL int XGDMatrixCreateFromCSREx(const size_t *indptr, const unsigned *indices,
159  const float *data, size_t nindptr, size_t nelem,
160  size_t num_col, DMatrixHandle *out);
215 XGB_DLL int XGDMatrixCreateFromColumnar(char const *data, char const *config, DMatrixHandle *out);
216 
231 XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data,
232  bst_ulong ncol, char const *config, DMatrixHandle *out);
233 
249 XGB_DLL int XGDMatrixCreateFromDense(char const *data, char const *config, DMatrixHandle *out);
250 
263 XGB_DLL int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char const *data,
264  bst_ulong nrow, char const *config, DMatrixHandle *out);
265 
271 XGB_DLL int XGDMatrixCreateFromCSCEx(const size_t *col_ptr, const unsigned *indices,
272  const float *data, size_t nindptr, size_t nelem,
273  size_t num_row, DMatrixHandle *out);
274 
284 XGB_DLL int XGDMatrixCreateFromMat(const float *data,
285  bst_ulong nrow,
286  bst_ulong ncol,
287  float missing,
288  DMatrixHandle *out);
299 XGB_DLL int XGDMatrixCreateFromMat_omp(const float *data, // NOLINT
300  bst_ulong nrow, bst_ulong ncol,
301  float missing, DMatrixHandle *out,
302  int nthread);
303 
315 XGB_DLL int XGDMatrixCreateFromCudaColumnar(char const *data, char const *config,
316  DMatrixHandle *out);
317 
328 XGB_DLL int XGDMatrixCreateFromCudaArrayInterface(char const *data, char const *config,
329  DMatrixHandle *out);
330 
382 /* ==== First set of callback functions, used exclusively by JVM packages. ==== */
383 
385 typedef void *DataIterHandle; // NOLINT(*)
387 typedef void *DataHolderHandle; // NOLINT(*)
388 
389 
391 typedef struct { // NOLINT(*)
393  size_t size;
394  /* \brief number of columns in the minibatch. */
395  size_t columns;
397 #ifdef __APPLE__
398  /* Necessary as Java on MacOS defines jlong as long int
399  * and gcc defines int64_t as long long int. */
400  long* offset; // NOLINT(*)
401 #else
402  int64_t* offset; // NOLINT(*)
403 #endif // __APPLE__
405  float* label;
407  float* weight;
409  int* index;
411  float* value;
413 
419 XGB_EXTERN_C typedef int XGBCallbackSetData( // NOLINT(*)
420  DataHolderHandle handle, XGBoostBatchCSR batch);
421 
433 XGB_EXTERN_C typedef int XGBCallbackDataIterNext( // NOLINT(*)
434  DataIterHandle data_handle, XGBCallbackSetData *set_function,
435  DataHolderHandle set_function_handle);
436 
447  DataIterHandle data_handle,
448  XGBCallbackDataIterNext* callback,
449  const char* cache_info,
450  float missing,
451  DMatrixHandle *out);
452 
479 
487 XGB_EXTERN_C typedef int XGDMatrixCallbackNext(DataIterHandle iter); // NOLINT(*)
488 
492 XGB_EXTERN_C typedef void DataIterResetCallback(DataIterHandle handle); // NOLINT(*)
493 
494 
520  char const *config, DMatrixHandle *out);
560  XGDMatrixCallbackNext *next, char const *config,
561  DMatrixHandle *out);
562 
600  DataIterHandle ref,
601  DataIterResetCallback *reset,
602  XGDMatrixCallbackNext *next,
603  char const *config, DMatrixHandle *out);
604 
615 
625 
635 
645 XGB_DLL int XGProxyDMatrixSetDataDense(DMatrixHandle handle, char const *data);
646 
658 XGB_DLL int XGProxyDMatrixSetDataCSR(DMatrixHandle handle, char const *indptr,
659  char const *indices, char const *data,
660  bst_ulong ncol);
661  // End of Streaming
663 
673  const int *idxset,
674  bst_ulong len,
675  DMatrixHandle *out);
686  const int *idxset,
687  bst_ulong len,
688  DMatrixHandle *out,
689  int allow_groups);
710  const char *fname, int silent);
711 
722  char const *data);
723 
732 XGB_DLL int XGDMatrixSetFloatInfo(DMatrixHandle handle, const char *field, const float *array,
733  bst_ulong len);
739 XGB_DLL int XGDMatrixSetUIntInfo(DMatrixHandle handle, const char *field, const unsigned *array,
740  bst_ulong len);
741 
768 XGB_DLL int XGDMatrixSetStrFeatureInfo(DMatrixHandle handle, const char *field,
769  const char **features,
770  const bst_ulong size);
771 
807 XGB_DLL int XGDMatrixGetStrFeatureInfo(DMatrixHandle handle, const char *field,
808  bst_ulong *size,
809  const char ***out_features);
810 
816 XGB_DLL int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field, void const *data,
817  bst_ulong size, int type);
818 
827 XGB_DLL int XGDMatrixGetFloatInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
828  const float **out_dptr);
842  const char *field,
843  bst_ulong* out_len,
844  const unsigned **out_dptr);
859 
869 
879 
900 XGB_DLL int XGDMatrixGetDataAsCSR(DMatrixHandle const handle, char const *config,
901  bst_ulong *out_indptr, unsigned *out_indices, float *out_data);
902 
918 XGB_DLL int XGDMatrixGetQuantileCut(DMatrixHandle const handle, char const *config,
919  char const **out_indptr, char const **out_data);
920  // End of DMatrix
922 
970 
984 XGB_DLL int XGBoosterSlice(BoosterHandle handle, int begin_layer,
985  int end_layer, int step,
986  BoosterHandle *out);
987 
996 
1005  const char *name,
1006  const char *value);
1038  float *hess, bst_ulong len);
1039 
1056  char const *grad, char const *hess);
1057 
1069  const char *evnames[], bst_ulong len, const char **out_result);
1110  DMatrixHandle dmat,
1111  int option_mask,
1112  unsigned ntree_limit,
1113  int training,
1114  bst_ulong *out_len,
1115  const float **out_result);
1116 
1176  char const *config, bst_ulong const **out_shape,
1177  bst_ulong *out_dim, float const **out_result);
1202 XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *values, char const *config,
1203  DMatrixHandle m, bst_ulong const **out_shape,
1204  bst_ulong *out_dim, const float **out_result);
1229 XGB_DLL int XGBoosterPredictFromColumnar(BoosterHandle handle, char const *values,
1230  char const *config, DMatrixHandle m,
1231  bst_ulong const **out_shape, bst_ulong *out_dim,
1232  const float **out_result);
1233 
1257 XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
1258  char const *values, bst_ulong ncol, char const *config,
1259  DMatrixHandle m, bst_ulong const **out_shape,
1260  bst_ulong *out_dim, const float **out_result);
1261 
1281 XGB_DLL int XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values,
1282  char const *config, DMatrixHandle proxy,
1283  bst_ulong const **out_shape, bst_ulong *out_dim,
1284  const float **out_result);
1285 
1306  char const *config, DMatrixHandle proxy,
1307  bst_ulong const **out_shape, bst_ulong *out_dim,
1308  const float **out_result);
1309  // End of Prediction
1311 
1312 
1348  const char *fname);
1357  const char *fname);
1367  const void *buf,
1368  bst_ulong len);
1369 
1386 XGB_DLL int XGBoosterSaveModelToBuffer(BoosterHandle handle, char const *config, bst_ulong *out_len,
1387  char const **out_dptr);
1388 
1399  const char **out_dptr);
1410  const void *buf, bst_ulong len);
1411 
1425  char const **out_str);
1435 XGB_DLL int XGBoosterLoadJsonConfig(BoosterHandle handle, char const *config); // End of Serialization
1437 
1448  const char *fmap,
1449  int with_stats,
1450  bst_ulong *out_len,
1451  const char ***out_dump_array);
1452 
1464  const char *fmap,
1465  int with_stats,
1466  const char *format,
1467  bst_ulong *out_len,
1468  const char ***out_dump_array);
1469 
1482  int fnum,
1483  const char **fname,
1484  const char **ftype,
1485  int with_stats,
1486  bst_ulong *out_len,
1487  const char ***out_models);
1488 
1502  int fnum,
1503  const char **fname,
1504  const char **ftype,
1505  int with_stats,
1506  const char *format,
1507  bst_ulong *out_len,
1508  const char ***out_models);
1509 
1519  const char* key,
1520  const char** out,
1521  int *success);
1532  const char* key,
1533  const char* value);
1542  bst_ulong* out_len,
1543  const char*** out);
1544 
1560 XGB_DLL int XGBoosterSetStrFeatureInfo(BoosterHandle handle, const char *field,
1561  const char **features,
1562  const bst_ulong size);
1563 
1583 XGB_DLL int XGBoosterGetStrFeatureInfo(BoosterHandle handle, const char *field,
1584  bst_ulong *len,
1585  const char ***out_features);
1586 
1612 XGB_DLL int XGBoosterFeatureScore(BoosterHandle handle, const char *config,
1613  bst_ulong *out_n_features, char const ***out_features,
1614  bst_ulong *out_dim, bst_ulong const **out_shape,
1615  float const **out_scores); // End of Booster
1617 
1655 typedef void *TrackerHandle; /* NOLINT */
1656 
1687 XGB_DLL int XGTrackerCreate(char const *config, TrackerHandle *handle);
1688 
1698 XGB_DLL int XGTrackerWorkerArgs(TrackerHandle handle, char const **args);
1699 
1709 XGB_DLL int XGTrackerRun(TrackerHandle handle, char const *config);
1710 
1721 XGB_DLL int XGTrackerWaitFor(TrackerHandle handle, char const *config);
1722 
1733 
1768 XGB_DLL int XGCommunicatorInit(char const* config);
1769 
1778 
1785 
1792 
1799 
1809 XGB_DLL int XGCommunicatorPrint(char const *message);
1810 
1817 XGB_DLL int XGCommunicatorGetProcessorName(const char** name_str);
1818 
1834 XGB_DLL int XGCommunicatorBroadcast(void *send_receive_buffer, size_t size, int root);
1835 
1857 XGB_DLL int XGCommunicatorAllreduce(void *send_receive_buffer, size_t count, int data_type, int op);
1858  // End of Collective
1860 #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)
Delete the booster.
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)
int XGBoosterTrainOneIter(BoosterHandle handle, DMatrixHandle dtrain, int iter, char const *grad, char const *hess)
Update a model with gradient and Hessian. This is used for training with a custom objective function.
int XGBoosterCreate(const DMatrixHandle dmats[], bst_ulong len, BoosterHandle *out)
Create a XGBoost learner (booster)
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 XGBoosterReset(BoosterHandle handle)
Reset the booster object to release data caches used for training.
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 XGTrackerRun(TrackerHandle handle, char const *config)
Start the tracker. The tracker runs in the background and this function returns once the tracker is s...
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 XGTrackerWaitFor(TrackerHandle handle, char const *config)
Wait for the tracker to finish, should be called after XGTrackerRun(). This function will block until...
int XGCommunicatorGetWorldSize(void)
Get the total number of processes.
int XGTrackerCreate(char const *config, TrackerHandle *handle)
Create a new tracker.
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 the current process.
int XGCommunicatorPrint(char const *message)
Print the message to the tracker.
int XGCommunicatorInit(char const *config)
Initialize the collective communicator.
void * TrackerHandle
Handle to the tracker.
Definition: c_api.h:1655
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 XGTrackerFree(TrackerHandle handle)
Free a tracker instance. This should be called after XGTrackerWaitFor(). If the tracker is not proper...
int XGTrackerWorkerArgs(TrackerHandle handle, char const **args)
Get the arguments needed for running workers. This should be called after XGTrackerRun().
int XGDMatrixDataSplitMode(DMatrixHandle handle, bst_ulong *out)
Get the data split mode from DMatrix.
int XGDMatrixSetUIntInfo(DMatrixHandle handle, const char *field, const unsigned *array, bst_ulong len)
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 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 DMatrix from dense array.
int XGDMatrixSaveBinary(DMatrixHandle handle, const char *fname, int silent)
Save the DMatrix object into a file. QuantileDMatrix and external memory DMatrix are not supported.
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 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 DMatrix from CSR matrix.
int XGDMatrixCreateFromFile(const char *fname, int silent, DMatrixHandle *out)
load a data 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 XGDMatrixSetInfoFromInterface(DMatrixHandle handle, char const *field, char const *data)
Set content in array interface to a content in info.
int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field, void const *data, bst_ulong size, int type)
int XGDMatrixCreateFromColumnar(char const *data, char const *config, DMatrixHandle *out)
Create a DMatrix from columnar 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 DMatrix 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 XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values, char const *config, DMatrixHandle proxy, bst_ulong const **out_shape, bst_ulong *out_dim, const float **out_result)
Inplace prediction from CUDA Dense matrix (cupy in Python).
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 XGBoosterPredictFromCudaColumnar(BoosterHandle handle, char const *data, char const *config, DMatrixHandle proxy, bst_ulong const **out_shape, bst_ulong *out_dim, const float **out_result)
Inplace prediction from CUDA dense dataframe (cuDF in Python).
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 XGBoosterPredictFromColumnar(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 columnar data. (Table)
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 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 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.
void * DataHolderHandle
handle to an internal data holder.
Definition: c_api.h:387
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:433
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:419
int XGDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, char const *config, DMatrixHandle *out)
Create an external memory DMatrix with data iterator.
int XGDMatrixCreateFromDataIter(DataIterHandle data_handle, XGBCallbackDataIterNext *callback, const char *cache_info, float missing, DMatrixHandle *out)
Create a DMatrix from a data iterator.
int XGProxyDMatrixSetDataColumnar(DMatrixHandle handle, char const *data)
Set columnar (table) data on a DMatrix proxy.
int XGProxyDMatrixCreate(DMatrixHandle *out)
Create a DMatrix proxy for setting data, can be freed by XGDMatrixFree.
int XGDMatrixCallbackNext(DataIterHandle iter)
Callback function prototype for getting next batch of data.
Definition: c_api.h:487
int XGProxyDMatrixSetDataDense(DMatrixHandle handle, char const *data)
Set data on a DMatrix proxy.
int XGExtMemQuantileDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy, DataIterHandle ref, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, char const *config, DMatrixHandle *out)
Create a Quantile DMatrix backed by external memory.
void * DataIterHandle
handle to a external data iterator
Definition: c_api.h:385
int XGQuantileDMatrixCreateFromCallback(DataIterHandle iter, DMatrixHandle proxy, DataIterHandle ref, DataIterResetCallback *reset, XGDMatrixCallbackNext *next, char const *config, DMatrixHandle *out)
Create a Quantile DMatrix with a data iterator.
int XGProxyDMatrixSetDataCudaColumnar(DMatrixHandle handle, const char *data)
Set CUDA-based columnar (table) data on a DMatrix proxy.
void DataIterResetCallback(DataIterHandle handle)
Callback function prototype for resetting the external iterator.
Definition: c_api.h:492
int XGProxyDMatrixSetDataCudaArrayInterface(DMatrixHandle handle, const char *data)
Set data on a DMatrix proxy.
Mini batch used in XGBoost Data Iteration.
Definition: c_api.h:391
int64_t * offset
row pointer to the rows in the data
Definition: c_api.h:402
int * index
feature index
Definition: c_api.h:409
float * value
feature values
Definition: c_api.h:411
size_t columns
Definition: c_api.h:395
float * weight
weight of each instance, can be NULL
Definition: c_api.h:407
size_t size
number of rows in the minibatch
Definition: c_api.h:393