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);
540  XGDMatrixCallbackNext *next, char const *config,
541  DMatrixHandle *out);
542 
580  DataIterHandle ref,
581  DataIterResetCallback *reset,
582  XGDMatrixCallbackNext *next,
583  char const *config, DMatrixHandle *out);
584 
595 
605 
615 
625 XGB_DLL int XGProxyDMatrixSetDataDense(DMatrixHandle handle, char const *data);
626 
638 XGB_DLL int XGProxyDMatrixSetDataCSR(DMatrixHandle handle, char const *indptr, char const *indices,
639  char const *data, bst_ulong ncol);
640  // End of Streaming
642 
651 XGB_DLL int XGDMatrixSliceDMatrix(DMatrixHandle handle, const int *idxset, bst_ulong len,
652  DMatrixHandle *out);
662 XGB_DLL int XGDMatrixSliceDMatrixEx(DMatrixHandle handle, const int *idxset, bst_ulong len,
663  DMatrixHandle *out, int allow_groups);
684 XGB_DLL int XGDMatrixSaveBinary(DMatrixHandle handle, const char *fname, int silent);
685 
696  char const *data);
697 
706 XGB_DLL int XGDMatrixSetFloatInfo(DMatrixHandle handle, const char *field, const float *array,
707  bst_ulong len);
713 XGB_DLL int XGDMatrixSetUIntInfo(DMatrixHandle handle, const char *field, const unsigned *array,
714  bst_ulong len);
715 
742 XGB_DLL int XGDMatrixSetStrFeatureInfo(DMatrixHandle handle, const char *field,
743  const char **features, const bst_ulong size);
744 
780 XGB_DLL int XGDMatrixGetStrFeatureInfo(DMatrixHandle handle, const char *field, bst_ulong *size,
781  const char ***out_features);
782 
813 XGB_DLL int XGDMatrixGetCategories(DMatrixHandle handle, char const *config, CategoriesHandle *out);
814 
832  CategoriesHandle *out, char const **export_out);
833 
846 
852 XGB_DLL int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field, void const *data,
853  bst_ulong size, int type);
854 
871 XGB_DLL int XGDMatrixGetInfoRef(DMatrixHandle handle, char const *field, char const **out_array);
872 
881 XGB_DLL int XGDMatrixGetFloatInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
882  const float **out_dptr);
895 XGB_DLL int XGDMatrixGetUIntInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
896  const unsigned **out_dptr);
913 
923 
933 
954 XGB_DLL int XGDMatrixGetDataAsCSR(DMatrixHandle const handle, char const *config,
955  bst_ulong *out_indptr, unsigned *out_indices, float *out_data);
956 
972 XGB_DLL int XGDMatrixGetQuantileCut(DMatrixHandle const handle, char const *config,
973  char const **out_indptr, char const **out_data);
974  // End of DMatrix
976 
1024 
1038 XGB_DLL int XGBoosterSlice(BoosterHandle handle, int begin_layer, int end_layer, int step,
1039  BoosterHandle *out);
1040 
1049 
1057 XGB_DLL int XGBoosterSetParam(BoosterHandle handle, const char *name, const char *value);
1089  float *hess, bst_ulong len);
1090 
1107  char const *grad, char const *hess);
1108 
1120  const char *evnames[], bst_ulong len, const char **out_result);
1160 XGB_DLL int XGBoosterPredict(BoosterHandle handle, DMatrixHandle dmat, int option_mask,
1161  unsigned ntree_limit, int training, bst_ulong *out_len,
1162  const float **out_result);
1163 
1223  char const *config, bst_ulong const **out_shape,
1224  bst_ulong *out_dim, float const **out_result);
1249 XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *values, char const *config,
1250  DMatrixHandle m, bst_ulong const **out_shape,
1251  bst_ulong *out_dim, const float **out_result);
1276 XGB_DLL int XGBoosterPredictFromColumnar(BoosterHandle handle, char const *values,
1277  char const *config, DMatrixHandle m,
1278  bst_ulong const **out_shape, bst_ulong *out_dim,
1279  const float **out_result);
1280 
1304 XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
1305  char const *values, bst_ulong ncol, char const *config,
1306  DMatrixHandle m, bst_ulong const **out_shape,
1307  bst_ulong *out_dim, const float **out_result);
1308 
1328 XGB_DLL int XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values,
1329  char const *config, DMatrixHandle proxy,
1330  bst_ulong const **out_shape, bst_ulong *out_dim,
1331  const float **out_result);
1332 
1353  char const *config, DMatrixHandle proxy,
1354  bst_ulong const **out_shape, bst_ulong *out_dim,
1355  const float **out_result);
1356  // End of Prediction
1358 
1393 XGB_DLL int XGBoosterLoadModel(BoosterHandle handle, const char *fname);
1402 XGB_DLL int XGBoosterSaveModel(BoosterHandle handle, const char *fname);
1412 
1429 XGB_DLL int XGBoosterSaveModelToBuffer(BoosterHandle handle, char const *config, bst_ulong *out_len,
1430  char const **out_dptr);
1431 
1442  const char **out_dptr);
1453 
1466 XGB_DLL int XGBoosterSaveJsonConfig(BoosterHandle handle, bst_ulong *out_len, char const **out_str);
1476 XGB_DLL int XGBoosterLoadJsonConfig(BoosterHandle handle, char const *config); // End of Serialization
1478 
1488 XGB_DLL int XGBoosterDumpModel(BoosterHandle handle, const char *fmap, int with_stats,
1489  bst_ulong *out_len, const char ***out_dump_array);
1490 
1501 XGB_DLL int XGBoosterDumpModelEx(BoosterHandle handle, const char *fmap, int with_stats,
1502  const char *format, bst_ulong *out_len,
1503  const char ***out_dump_array);
1504 
1516 XGB_DLL int XGBoosterDumpModelWithFeatures(BoosterHandle handle, int fnum, const char **fname,
1517  const char **ftype, int with_stats, bst_ulong *out_len,
1518  const char ***out_models);
1519 
1532 XGB_DLL int XGBoosterDumpModelExWithFeatures(BoosterHandle handle, int fnum, const char **fname,
1533  const char **ftype, int with_stats, const char *format,
1534  bst_ulong *out_len, const char ***out_models);
1535 
1543 XGB_DLL int XGBoosterGetCategories(BoosterHandle handle, char const *config, CategoriesHandle *out);
1544 
1553  CategoriesHandle *out, char const **export_out);
1554 
1563 XGB_DLL int XGBoosterGetAttr(BoosterHandle handle, const char *key, const char **out, int *success);
1573 XGB_DLL int XGBoosterSetAttr(BoosterHandle handle, const char *key, const char *value);
1581 XGB_DLL int XGBoosterGetAttrNames(BoosterHandle handle, bst_ulong *out_len, const char ***out);
1582 
1598 XGB_DLL int XGBoosterSetStrFeatureInfo(BoosterHandle handle, const char *field,
1599  const char **features, const bst_ulong size);
1600 
1620 XGB_DLL int XGBoosterGetStrFeatureInfo(BoosterHandle handle, const char *field, bst_ulong *len,
1621  const char ***out_features);
1622 
1648 XGB_DLL int XGBoosterFeatureScore(BoosterHandle handle, const char *config,
1649  bst_ulong *out_n_features, char const ***out_features,
1650  bst_ulong *out_dim, bst_ulong const **out_shape,
1651  float const **out_scores); // End of Booster
1653 
1691 typedef void *TrackerHandle; /* NOLINT */
1692 
1723 XGB_DLL int XGTrackerCreate(char const *config, TrackerHandle *handle);
1724 
1734 XGB_DLL int XGTrackerWorkerArgs(TrackerHandle handle, char const **args);
1735 
1745 XGB_DLL int XGTrackerRun(TrackerHandle handle, char const *config);
1746 
1757 XGB_DLL int XGTrackerWaitFor(TrackerHandle handle, char const *config);
1758 
1769 
1804 XGB_DLL int XGCommunicatorInit(char const *config);
1805 
1814 
1821 
1828 
1835 
1845 XGB_DLL int XGCommunicatorPrint(char const *message);
1846 
1853 XGB_DLL int XGCommunicatorGetProcessorName(const char **name_str);
1854 
1871 XGB_DLL int XGCommunicatorBroadcast(void *send_receive_buffer, size_t size, int root);
1872 
1894 XGB_DLL int XGCommunicatorAllreduce(void *send_receive_buffer, size_t count, int data_type, int op);
1895  // End of Collective
1897 #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:1691
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