xgboost
c_api.h
Go to the documentation of this file.
1 
6 #ifndef XGBOOST_C_API_H_
7 #define XGBOOST_C_API_H_
8 
9 #ifdef __cplusplus
10 #define XGB_EXTERN_C extern "C"
11 #include <cstddef>
12 #include <cstdint>
13 #include <cstdio>
14 #else
15 #define XGB_EXTERN_C
16 #include <stddef.h>
17 #include <stdint.h>
18 #include <stdio.h>
19 #endif // __cplusplus
20 
21 #if defined(_MSC_VER) || defined(_WIN32)
22 #define XGB_DLL XGB_EXTERN_C __declspec(dllexport)
23 #else
24 #define XGB_DLL XGB_EXTERN_C __attribute__((visibility("default")))
25 #endif // defined(_MSC_VER) || defined(_WIN32)
26 
27 // manually define unsigned long
28 typedef uint64_t bst_ulong; // NOLINT(*)
29 
49 typedef void *DMatrixHandle; // NOLINT(*)
51 typedef void *BoosterHandle; // NOLINT(*)
57 typedef void *CategoriesHandle; // NOLINT(*)
58 
68 XGB_DLL void XGBoostVersion(int *major, int *minor, int *patch);
69 
77 XGB_DLL int XGBuildInfo(char const **out);
78 
90 XGB_DLL const char *XGBGetLastError();
91 
101 XGB_DLL int XGBRegisterLogCallback(void (*callback)(const char *));
102 
111 XGB_DLL int XGBSetGlobalConfig(char const *config);
112 
118 XGB_DLL int XGBGetGlobalConfig(char const **out_config);
119 
146 XGB_DLL int XGDMatrixCreateFromFile(const char *fname, int silent, DMatrixHandle *out);
147 
161 XGB_DLL int XGDMatrixCreateFromURI(char const *config, DMatrixHandle *out);
162 
217 XGB_DLL int XGDMatrixCreateFromColumnar(char const *data, char const *config, DMatrixHandle *out);
218 
233 XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data,
234  bst_ulong ncol, char const *config, DMatrixHandle *out);
235 
251 XGB_DLL int XGDMatrixCreateFromDense(char const *data, char const *config, DMatrixHandle *out);
252 
265 XGB_DLL int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char const *data,
266  bst_ulong nrow, char const *config, DMatrixHandle *out);
267 
277 XGB_DLL int XGDMatrixCreateFromMat(const float *data, bst_ulong nrow, bst_ulong ncol, float missing,
278  DMatrixHandle *out);
289 XGB_DLL int XGDMatrixCreateFromMat_omp(const float *data, // NOLINT
290  bst_ulong nrow, bst_ulong ncol, float missing,
291  DMatrixHandle *out, int nthread);
292 
304 XGB_DLL int XGDMatrixCreateFromCudaColumnar(char const *data, char const *config,
305  DMatrixHandle *out);
306 
317 XGB_DLL int XGDMatrixCreateFromCudaArrayInterface(char const *data, char const *config,
318  DMatrixHandle *out);
319 
371 /* ==== First set of callback functions, used exclusively by JVM packages. ==== */
372 
374 typedef void *DataIterHandle; // NOLINT(*)
376 typedef void *DataHolderHandle; // NOLINT(*)
377 
379 typedef struct { // NOLINT(*)
381  size_t size;
383  size_t columns;
385 #ifdef __APPLE__
386  /* Necessary as Java on MacOS defines jlong as long int
387  * and gcc defines int64_t as long long int. */
388  long *offset; // NOLINT(*)
389 #else
390  int64_t *offset; // NOLINT(*)
391 #endif // __APPLE__
393  float *label;
395  float *weight;
397  int *index;
399  float *value;
401 
407 XGB_EXTERN_C typedef int XGBCallbackSetData( // NOLINT(*)
408  DataHolderHandle handle, XGBoostBatchCSR batch);
409 
421 XGB_EXTERN_C typedef int XGBCallbackDataIterNext( // NOLINT(*)
422  DataIterHandle data_handle, XGBCallbackSetData *set_function,
423  DataHolderHandle set_function_handle);
424 
435  XGBCallbackDataIterNext *callback, const char *cache_info,
436  float missing, DMatrixHandle *out);
437 
464 
472 XGB_EXTERN_C typedef int XGDMatrixCallbackNext(DataIterHandle iter); // NOLINT(*)
473 
477 XGB_EXTERN_C typedef void DataIterResetCallback(DataIterHandle handle); // NOLINT(*)
478 
504  char const *config, DMatrixHandle *out);
544  XGDMatrixCallbackNext *next, char const *config,
545  DMatrixHandle *out);
546 
588  DataIterHandle ref,
589  DataIterResetCallback *reset,
590  XGDMatrixCallbackNext *next,
591  char const *config, DMatrixHandle *out);
592 
603 
613 
623 
633 XGB_DLL int XGProxyDMatrixSetDataDense(DMatrixHandle handle, char const *data);
634 
646 XGB_DLL int XGProxyDMatrixSetDataCSR(DMatrixHandle handle, char const *indptr, char const *indices,
647  char const *data, bst_ulong ncol);
648  // End of Streaming
650 
659 XGB_DLL int XGDMatrixSliceDMatrix(DMatrixHandle handle, const int *idxset, bst_ulong len,
660  DMatrixHandle *out);
670 XGB_DLL int XGDMatrixSliceDMatrixEx(DMatrixHandle handle, const int *idxset, bst_ulong len,
671  DMatrixHandle *out, int allow_groups);
692 XGB_DLL int XGDMatrixSaveBinary(DMatrixHandle handle, const char *fname, int silent);
693 
704  char const *data);
705 
714 XGB_DLL int XGDMatrixSetFloatInfo(DMatrixHandle handle, const char *field, const float *array,
715  bst_ulong len);
721 XGB_DLL int XGDMatrixSetUIntInfo(DMatrixHandle handle, const char *field, const unsigned *array,
722  bst_ulong len);
723 
750 XGB_DLL int XGDMatrixSetStrFeatureInfo(DMatrixHandle handle, const char *field,
751  const char **features, const bst_ulong size);
752 
788 XGB_DLL int XGDMatrixGetStrFeatureInfo(DMatrixHandle handle, const char *field, bst_ulong *size,
789  const char ***out_features);
790 
821 XGB_DLL int XGDMatrixGetCategories(DMatrixHandle handle, char const *config, CategoriesHandle *out);
822 
840  CategoriesHandle *out, char const **export_out);
841 
854 
860 XGB_DLL int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field, void const *data,
861  bst_ulong size, int type);
862 
879 XGB_DLL int XGDMatrixGetInfoRef(DMatrixHandle handle, char const *field, char const **out_array);
880 
889 XGB_DLL int XGDMatrixGetFloatInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
890  const float **out_dptr);
903 XGB_DLL int XGDMatrixGetUIntInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
904  const unsigned **out_dptr);
921 
931 
941 
962 XGB_DLL int XGDMatrixGetDataAsCSR(DMatrixHandle const handle, char const *config,
963  bst_ulong *out_indptr, unsigned *out_indices, float *out_data);
964 
980 XGB_DLL int XGDMatrixGetQuantileCut(DMatrixHandle const handle, char const *config,
981  char const **out_indptr, char const **out_data);
982  // End of DMatrix
984 
1032 
1046 XGB_DLL int XGBoosterSlice(BoosterHandle handle, int begin_layer, int end_layer, int step,
1047  BoosterHandle *out);
1048 
1057 
1065 XGB_DLL int XGBoosterSetParam(BoosterHandle handle, const char *name, const char *value);
1097  float *hess, bst_ulong len);
1098 
1115  char const *grad, char const *hess);
1116 
1128  const char *evnames[], bst_ulong len, const char **out_result);
1168 XGB_DLL int XGBoosterPredict(BoosterHandle handle, DMatrixHandle dmat, int option_mask,
1169  unsigned ntree_limit, int training, bst_ulong *out_len,
1170  const float **out_result);
1171 
1231  char const *config, bst_ulong const **out_shape,
1232  bst_ulong *out_dim, float const **out_result);
1257 XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *values, char const *config,
1258  DMatrixHandle m, bst_ulong const **out_shape,
1259  bst_ulong *out_dim, const float **out_result);
1284 XGB_DLL int XGBoosterPredictFromColumnar(BoosterHandle handle, char const *values,
1285  char const *config, DMatrixHandle m,
1286  bst_ulong const **out_shape, bst_ulong *out_dim,
1287  const float **out_result);
1288 
1312 XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
1313  char const *values, bst_ulong ncol, char const *config,
1314  DMatrixHandle m, bst_ulong const **out_shape,
1315  bst_ulong *out_dim, const float **out_result);
1316 
1336 XGB_DLL int XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values,
1337  char const *config, DMatrixHandle proxy,
1338  bst_ulong const **out_shape, bst_ulong *out_dim,
1339  const float **out_result);
1340 
1361  char const *config, DMatrixHandle proxy,
1362  bst_ulong const **out_shape, bst_ulong *out_dim,
1363  const float **out_result);
1364  // End of Prediction
1366 
1401 XGB_DLL int XGBoosterLoadModel(BoosterHandle handle, const char *fname);
1410 XGB_DLL int XGBoosterSaveModel(BoosterHandle handle, const char *fname);
1420 
1437 XGB_DLL int XGBoosterSaveModelToBuffer(BoosterHandle handle, char const *config, bst_ulong *out_len,
1438  char const **out_dptr);
1439 
1450  const char **out_dptr);
1461 
1474 XGB_DLL int XGBoosterSaveJsonConfig(BoosterHandle handle, bst_ulong *out_len, char const **out_str);
1484 XGB_DLL int XGBoosterLoadJsonConfig(BoosterHandle handle, char const *config); // End of Serialization
1486 
1496 XGB_DLL int XGBoosterDumpModel(BoosterHandle handle, const char *fmap, int with_stats,
1497  bst_ulong *out_len, const char ***out_dump_array);
1498 
1509 XGB_DLL int XGBoosterDumpModelEx(BoosterHandle handle, const char *fmap, int with_stats,
1510  const char *format, bst_ulong *out_len,
1511  const char ***out_dump_array);
1512 
1524 XGB_DLL int XGBoosterDumpModelWithFeatures(BoosterHandle handle, int fnum, const char **fname,
1525  const char **ftype, int with_stats, bst_ulong *out_len,
1526  const char ***out_models);
1527 
1540 XGB_DLL int XGBoosterDumpModelExWithFeatures(BoosterHandle handle, int fnum, const char **fname,
1541  const char **ftype, int with_stats, const char *format,
1542  bst_ulong *out_len, const char ***out_models);
1543 
1551 XGB_DLL int XGBoosterGetCategories(BoosterHandle handle, char const *config, CategoriesHandle *out);
1552 
1561  CategoriesHandle *out, char const **export_out);
1562 
1571 XGB_DLL int XGBoosterGetAttr(BoosterHandle handle, const char *key, const char **out, int *success);
1581 XGB_DLL int XGBoosterSetAttr(BoosterHandle handle, const char *key, const char *value);
1589 XGB_DLL int XGBoosterGetAttrNames(BoosterHandle handle, bst_ulong *out_len, const char ***out);
1590 
1606 XGB_DLL int XGBoosterSetStrFeatureInfo(BoosterHandle handle, const char *field,
1607  const char **features, const bst_ulong size);
1608 
1628 XGB_DLL int XGBoosterGetStrFeatureInfo(BoosterHandle handle, const char *field, bst_ulong *len,
1629  const char ***out_features);
1630 
1656 XGB_DLL int XGBoosterFeatureScore(BoosterHandle handle, const char *config,
1657  bst_ulong *out_n_features, char const ***out_features,
1658  bst_ulong *out_dim, bst_ulong const **out_shape,
1659  float const **out_scores); // End of Booster
1661 
1699 typedef void *TrackerHandle; /* NOLINT */
1700 
1731 XGB_DLL int XGTrackerCreate(char const *config, TrackerHandle *handle);
1732 
1742 XGB_DLL int XGTrackerWorkerArgs(TrackerHandle handle, char const **args);
1743 
1753 XGB_DLL int XGTrackerRun(TrackerHandle handle, char const *config);
1754 
1765 XGB_DLL int XGTrackerWaitFor(TrackerHandle handle, char const *config);
1766 
1777 
1812 XGB_DLL int XGCommunicatorInit(char const *config);
1813 
1822 
1829 
1836 
1843 
1853 XGB_DLL int XGCommunicatorPrint(char const *message);
1854 
1861 XGB_DLL int XGCommunicatorGetProcessorName(const char **name_str);
1862 
1879 XGB_DLL int XGCommunicatorBroadcast(void *send_receive_buffer, size_t size, int root);
1880 
1902 XGB_DLL int XGCommunicatorAllreduce(void *send_receive_buffer, size_t count, int data_type, int op);
1903  // End of Collective
1905 #endif // XGBOOST_C_API_H_
#define XGB_EXTERN_C
C API of XGBoost, used to interface with other high-level languages.
Definition: c_api.h:15
#define XGB_DLL
Definition: c_api.h:24
uint64_t bst_ulong
Definition: c_api.h:28
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 XGBoosterGetCategories(BoosterHandle handle, char const *config, CategoriesHandle *out)
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 the 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 XGBoosterGetCategoriesExportToArrow(BoosterHandle handle, char const *config, CategoriesHandle *out, char const **export_out)
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:1699
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 XGDMatrixGetCategories(DMatrixHandle handle, char const *config, CategoriesHandle *out)
Create an opaque handle to the internal category container.
int XGDMatrixFree(DMatrixHandle handle)
Free a DMatrix object.
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 the number of rows from a DMatrix.
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 a 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 the number of columns from a DMatrix.
int XGDMatrixSetFloatInfo(DMatrixHandle handle, const char *field, const float *array, bst_ulong len)
set float vector to a content in info
int XGDMatrixGetInfoRef(DMatrixHandle handle, char const *field, char const **out_array)
Get a reference to data like label or weight.
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 XGDMatrixGetCategoriesExportToArrow(DMatrixHandle handle, char const *config, CategoriesHandle *out, char const **export_out)
Create an opaque handle to the internal container and export it to arrow.
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 XGBCategoriesFree(CategoriesHandle handle)
Free the opaque handle.
int XGBGetGlobalConfig(char const **out_config)
Get current global configuration (collection of parameters that apply globally).
void * BoosterHandle
Handle to the Booster.
Definition: c_api.h:51
const char * XGBGetLastError()
Get the string message of the last error.
void * CategoriesHandle
Handle to the categories container.
Definition: c_api.h:57
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 the shared XGBoost library.
void * DMatrixHandle
Handle to the DMatrix.
Definition: c_api.h:49
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.
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:376
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:421
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:407
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:472
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:374
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:477
int XGProxyDMatrixSetDataCudaArrayInterface(DMatrixHandle handle, const char *data)
Set data on a DMatrix proxy.
Mini batch used in XGBoost Data Iteration.
Definition: c_api.h:379
int64_t * offset
row pointer to the rows in the data
Definition: c_api.h:390
int * index
feature index
Definition: c_api.h:397
float * value
feature values
Definition: c_api.h:399
size_t columns
number of columns in the minibatch.
Definition: c_api.h:383
float * weight
weight of each instance, can be NULL
Definition: c_api.h:395
size_t size
number of rows in the minibatch
Definition: c_api.h:381