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 
206 XGB_DLL int XGDMatrixCreateFromColumnar(char const *data, char const *config, DMatrixHandle *out);
207 
222 XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data,
223  bst_ulong ncol, char const *config, DMatrixHandle *out);
224 
240 XGB_DLL int XGDMatrixCreateFromDense(char const *data, char const *config, DMatrixHandle *out);
241 
254 XGB_DLL int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char const *data,
255  bst_ulong nrow, char const *config, DMatrixHandle *out);
256 
257 
267 XGB_DLL int XGDMatrixCreateFromMat(const float *data,
268  bst_ulong nrow,
269  bst_ulong ncol,
270  float missing,
271  DMatrixHandle *out);
282 XGB_DLL int XGDMatrixCreateFromMat_omp(const float *data, // NOLINT
283  bst_ulong nrow, bst_ulong ncol,
284  float missing, DMatrixHandle *out,
285  int nthread);
286 
298 XGB_DLL int XGDMatrixCreateFromCudaColumnar(char const *data, char const *config,
299  DMatrixHandle *out);
300 
311 XGB_DLL int XGDMatrixCreateFromCudaArrayInterface(char const *data, char const *config,
312  DMatrixHandle *out);
313 
365 /* ==== First set of callback functions, used exclusively by JVM packages. ==== */
366 
368 typedef void *DataIterHandle; // NOLINT(*)
370 typedef void *DataHolderHandle; // NOLINT(*)
371 
372 
374 typedef struct { // NOLINT(*)
376  size_t size;
377  /* \brief number of columns in the minibatch. */
378  size_t columns;
380 #ifdef __APPLE__
381  /* Necessary as Java on MacOS defines jlong as long int
382  * and gcc defines int64_t as long long int. */
383  long* offset; // NOLINT(*)
384 #else
385  int64_t* offset; // NOLINT(*)
386 #endif // __APPLE__
388  float* label;
390  float* weight;
392  int* index;
394  float* value;
396 
402 XGB_EXTERN_C typedef int XGBCallbackSetData( // NOLINT(*)
403  DataHolderHandle handle, XGBoostBatchCSR batch);
404 
416 XGB_EXTERN_C typedef int XGBCallbackDataIterNext( // NOLINT(*)
417  DataIterHandle data_handle, XGBCallbackSetData *set_function,
418  DataHolderHandle set_function_handle);
419 
430  DataIterHandle data_handle,
431  XGBCallbackDataIterNext* callback,
432  const char* cache_info,
433  float missing,
434  DMatrixHandle *out);
435 
462 
470 XGB_EXTERN_C typedef int XGDMatrixCallbackNext(DataIterHandle iter); // NOLINT(*)
471 
475 XGB_EXTERN_C typedef void DataIterResetCallback(DataIterHandle handle); // NOLINT(*)
476 
477 
503  char const *config, DMatrixHandle *out);
543  XGDMatrixCallbackNext *next, char const *config,
544  DMatrixHandle *out);
545 
583  DataIterHandle ref,
584  DataIterResetCallback *reset,
585  XGDMatrixCallbackNext *next,
586  char const *config, DMatrixHandle *out);
587 
598 
608 
618 
628 XGB_DLL int XGProxyDMatrixSetDataDense(DMatrixHandle handle, char const *data);
629 
641 XGB_DLL int XGProxyDMatrixSetDataCSR(DMatrixHandle handle, char const *indptr,
642  char const *indices, char const *data,
643  bst_ulong ncol);
644  // End of Streaming
646 
656  const int *idxset,
657  bst_ulong len,
658  DMatrixHandle *out);
669  const int *idxset,
670  bst_ulong len,
671  DMatrixHandle *out,
672  int allow_groups);
693  const char *fname, int silent);
694 
705  char const *data);
706 
715 XGB_DLL int XGDMatrixSetFloatInfo(DMatrixHandle handle, const char *field, const float *array,
716  bst_ulong len);
722 XGB_DLL int XGDMatrixSetUIntInfo(DMatrixHandle handle, const char *field, const unsigned *array,
723  bst_ulong len);
724 
751 XGB_DLL int XGDMatrixSetStrFeatureInfo(DMatrixHandle handle, const char *field,
752  const char **features,
753  const bst_ulong size);
754 
790 XGB_DLL int XGDMatrixGetStrFeatureInfo(DMatrixHandle handle, const char *field,
791  bst_ulong *size,
792  const char ***out_features);
793 
799 XGB_DLL int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field, void const *data,
800  bst_ulong size, int type);
801 
810 XGB_DLL int XGDMatrixGetFloatInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
811  const float **out_dptr);
825  const char *field,
826  bst_ulong* out_len,
827  const unsigned **out_dptr);
842 
852 
862 
883 XGB_DLL int XGDMatrixGetDataAsCSR(DMatrixHandle const handle, char const *config,
884  bst_ulong *out_indptr, unsigned *out_indices, float *out_data);
885 
901 XGB_DLL int XGDMatrixGetQuantileCut(DMatrixHandle const handle, char const *config,
902  char const **out_indptr, char const **out_data);
903  // End of DMatrix
905 
953 
967 XGB_DLL int XGBoosterSlice(BoosterHandle handle, int begin_layer,
968  int end_layer, int step,
969  BoosterHandle *out);
970 
979 
988  const char *name,
989  const char *value);
1021  float *hess, bst_ulong len);
1022 
1039  char const *grad, char const *hess);
1040 
1052  const char *evnames[], bst_ulong len, const char **out_result);
1093  DMatrixHandle dmat,
1094  int option_mask,
1095  unsigned ntree_limit,
1096  int training,
1097  bst_ulong *out_len,
1098  const float **out_result);
1099 
1159  char const *config, bst_ulong const **out_shape,
1160  bst_ulong *out_dim, float const **out_result);
1185 XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *values, char const *config,
1186  DMatrixHandle m, bst_ulong const **out_shape,
1187  bst_ulong *out_dim, const float **out_result);
1212 XGB_DLL int XGBoosterPredictFromColumnar(BoosterHandle handle, char const *values,
1213  char const *config, DMatrixHandle m,
1214  bst_ulong const **out_shape, bst_ulong *out_dim,
1215  const float **out_result);
1216 
1240 XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
1241  char const *values, bst_ulong ncol, char const *config,
1242  DMatrixHandle m, bst_ulong const **out_shape,
1243  bst_ulong *out_dim, const float **out_result);
1244 
1264 XGB_DLL int XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values,
1265  char const *config, DMatrixHandle proxy,
1266  bst_ulong const **out_shape, bst_ulong *out_dim,
1267  const float **out_result);
1268 
1289  char const *config, DMatrixHandle proxy,
1290  bst_ulong const **out_shape, bst_ulong *out_dim,
1291  const float **out_result);
1292  // End of Prediction
1294 
1295 
1332  const char *fname);
1342  const char *fname);
1352  const void *buf,
1353  bst_ulong len);
1354 
1371 XGB_DLL int XGBoosterSaveModelToBuffer(BoosterHandle handle, char const *config, bst_ulong *out_len,
1372  char const **out_dptr);
1373 
1384  const char **out_dptr);
1395  const void *buf, bst_ulong len);
1396 
1410  char const **out_str);
1420 XGB_DLL int XGBoosterLoadJsonConfig(BoosterHandle handle, char const *config); // End of Serialization
1422 
1433  const char *fmap,
1434  int with_stats,
1435  bst_ulong *out_len,
1436  const char ***out_dump_array);
1437 
1449  const char *fmap,
1450  int with_stats,
1451  const char *format,
1452  bst_ulong *out_len,
1453  const char ***out_dump_array);
1454 
1467  int fnum,
1468  const char **fname,
1469  const char **ftype,
1470  int with_stats,
1471  bst_ulong *out_len,
1472  const char ***out_models);
1473 
1487  int fnum,
1488  const char **fname,
1489  const char **ftype,
1490  int with_stats,
1491  const char *format,
1492  bst_ulong *out_len,
1493  const char ***out_models);
1494 
1504  const char* key,
1505  const char** out,
1506  int *success);
1517  const char* key,
1518  const char* value);
1527  bst_ulong* out_len,
1528  const char*** out);
1529 
1545 XGB_DLL int XGBoosterSetStrFeatureInfo(BoosterHandle handle, const char *field,
1546  const char **features,
1547  const bst_ulong size);
1548 
1568 XGB_DLL int XGBoosterGetStrFeatureInfo(BoosterHandle handle, const char *field,
1569  bst_ulong *len,
1570  const char ***out_features);
1571 
1597 XGB_DLL int XGBoosterFeatureScore(BoosterHandle handle, const char *config,
1598  bst_ulong *out_n_features, char const ***out_features,
1599  bst_ulong *out_dim, bst_ulong const **out_shape,
1600  float const **out_scores); // End of Booster
1602 
1640 typedef void *TrackerHandle; /* NOLINT */
1641 
1672 XGB_DLL int XGTrackerCreate(char const *config, TrackerHandle *handle);
1673 
1683 XGB_DLL int XGTrackerWorkerArgs(TrackerHandle handle, char const **args);
1684 
1694 XGB_DLL int XGTrackerRun(TrackerHandle handle, char const *config);
1695 
1706 XGB_DLL int XGTrackerWaitFor(TrackerHandle handle, char const *config);
1707 
1718 
1753 XGB_DLL int XGCommunicatorInit(char const* config);
1754 
1763 
1770 
1777 
1784 
1794 XGB_DLL int XGCommunicatorPrint(char const *message);
1795 
1802 XGB_DLL int XGCommunicatorGetProcessorName(const char** name_str);
1803 
1819 XGB_DLL int XGCommunicatorBroadcast(void *send_receive_buffer, size_t size, int root);
1820 
1842 XGB_DLL int XGCommunicatorAllreduce(void *send_receive_buffer, size_t count, int data_type, int op);
1843  // End of Collective
1845 #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:1640
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 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 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 the model into an 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 the model from an 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:370
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:416
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:402
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:470
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:368
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:475
int XGProxyDMatrixSetDataCudaArrayInterface(DMatrixHandle handle, const char *data)
Set data on a DMatrix proxy.
Mini batch used in XGBoost Data Iteration.
Definition: c_api.h:374
int64_t * offset
row pointer to the rows in the data
Definition: c_api.h:385
int * index
feature index
Definition: c_api.h:392
float * value
feature values
Definition: c_api.h:394
size_t columns
Definition: c_api.h:378
float * weight
weight of each instance, can be NULL
Definition: c_api.h:390
size_t size
number of rows in the minibatch
Definition: c_api.h:376