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);
173 XGB_DLL int XGDMatrixCreateFromColumnar(char const *data, char const *config, DMatrixHandle *out);
174 
189 XGB_DLL int XGDMatrixCreateFromCSR(char const *indptr, char const *indices, char const *data,
190  bst_ulong ncol, char const *config, DMatrixHandle *out);
191 
207 XGB_DLL int XGDMatrixCreateFromDense(char const *data, char const *config, DMatrixHandle *out);
208 
221 XGB_DLL int XGDMatrixCreateFromCSC(char const *indptr, char const *indices, char const *data,
222  bst_ulong nrow, char const *config, DMatrixHandle *out);
223 
229 XGB_DLL int XGDMatrixCreateFromCSCEx(const size_t *col_ptr, const unsigned *indices,
230  const float *data, size_t nindptr, size_t nelem,
231  size_t num_row, DMatrixHandle *out);
232 
242 XGB_DLL int XGDMatrixCreateFromMat(const float *data,
243  bst_ulong nrow,
244  bst_ulong ncol,
245  float missing,
246  DMatrixHandle *out);
257 XGB_DLL int XGDMatrixCreateFromMat_omp(const float *data, // NOLINT
258  bst_ulong nrow, bst_ulong ncol,
259  float missing, DMatrixHandle *out,
260  int nthread);
261 
273 XGB_DLL int XGDMatrixCreateFromCudaColumnar(char const *data, char const *config,
274  DMatrixHandle *out);
275 
286 XGB_DLL int XGDMatrixCreateFromCudaArrayInterface(char const *data, char const *config,
287  DMatrixHandle *out);
288 
340 /* ==== First set of callback functions, used exclusively by JVM packages. ==== */
341 
343 typedef void *DataIterHandle; // NOLINT(*)
345 typedef void *DataHolderHandle; // NOLINT(*)
346 
347 
349 typedef struct { // NOLINT(*)
351  size_t size;
352  /* \brief number of columns in the minibatch. */
353  size_t columns;
355 #ifdef __APPLE__
356  /* Necessary as Java on MacOS defines jlong as long int
357  * and gcc defines int64_t as long long int. */
358  long* offset; // NOLINT(*)
359 #else
360  int64_t* offset; // NOLINT(*)
361 #endif // __APPLE__
363  float* label;
365  float* weight;
367  int* index;
369  float* value;
371 
377 XGB_EXTERN_C typedef int XGBCallbackSetData( // NOLINT(*)
378  DataHolderHandle handle, XGBoostBatchCSR batch);
379 
391 XGB_EXTERN_C typedef int XGBCallbackDataIterNext( // NOLINT(*)
392  DataIterHandle data_handle, XGBCallbackSetData *set_function,
393  DataHolderHandle set_function_handle);
394 
405  DataIterHandle data_handle,
406  XGBCallbackDataIterNext* callback,
407  const char* cache_info,
408  float missing,
409  DMatrixHandle *out);
410 
437 
445 XGB_EXTERN_C typedef int XGDMatrixCallbackNext(DataIterHandle iter); // NOLINT(*)
446 
450 XGB_EXTERN_C typedef void DataIterResetCallback(DataIterHandle handle); // NOLINT(*)
451 
452 
478  char const *config, DMatrixHandle *out);
518  XGDMatrixCallbackNext *next, char const *config,
519  DMatrixHandle *out);
520 
554  DataIterHandle ref,
555  DataIterResetCallback *reset,
556  XGDMatrixCallbackNext *next,
557  char const *config, DMatrixHandle *out);
558 
569 
579 
589 
599 XGB_DLL int XGProxyDMatrixSetDataDense(DMatrixHandle handle, char const *data);
600 
612 XGB_DLL int XGProxyDMatrixSetDataCSR(DMatrixHandle handle, char const *indptr,
613  char const *indices, char const *data,
614  bst_ulong ncol);
615  // End of Streaming
617 
627  const int *idxset,
628  bst_ulong len,
629  DMatrixHandle *out);
640  const int *idxset,
641  bst_ulong len,
642  DMatrixHandle *out,
643  int allow_groups);
664  const char *fname, int silent);
665 
676  char const *data);
677 
686 XGB_DLL int XGDMatrixSetFloatInfo(DMatrixHandle handle, const char *field, const float *array,
687  bst_ulong len);
693 XGB_DLL int XGDMatrixSetUIntInfo(DMatrixHandle handle, const char *field, const unsigned *array,
694  bst_ulong len);
695 
722 XGB_DLL int XGDMatrixSetStrFeatureInfo(DMatrixHandle handle, const char *field,
723  const char **features,
724  const bst_ulong size);
725 
761 XGB_DLL int XGDMatrixGetStrFeatureInfo(DMatrixHandle handle, const char *field,
762  bst_ulong *size,
763  const char ***out_features);
764 
770 XGB_DLL int XGDMatrixSetDenseInfo(DMatrixHandle handle, const char *field, void const *data,
771  bst_ulong size, int type);
772 
781 XGB_DLL int XGDMatrixGetFloatInfo(const DMatrixHandle handle, const char *field, bst_ulong *out_len,
782  const float **out_dptr);
796  const char *field,
797  bst_ulong* out_len,
798  const unsigned **out_dptr);
813 
823 
833 
854 XGB_DLL int XGDMatrixGetDataAsCSR(DMatrixHandle const handle, char const *config,
855  bst_ulong *out_indptr, unsigned *out_indices, float *out_data);
856 
872 XGB_DLL int XGDMatrixGetQuantileCut(DMatrixHandle const handle, char const *config,
873  char const **out_indptr, char const **out_data);
874  // End of DMatrix
876 
924 
938 XGB_DLL int XGBoosterSlice(BoosterHandle handle, int begin_layer,
939  int end_layer, int step,
940  BoosterHandle *out);
941 
950 
959  const char *name,
960  const char *value);
992  float *hess, bst_ulong len);
993 
1010  char const *grad, char const *hess);
1011 
1023  const char *evnames[], bst_ulong len, const char **out_result);
1064  DMatrixHandle dmat,
1065  int option_mask,
1066  unsigned ntree_limit,
1067  int training,
1068  bst_ulong *out_len,
1069  const float **out_result);
1070 
1130  char const *config, bst_ulong const **out_shape,
1131  bst_ulong *out_dim, float const **out_result);
1156 XGB_DLL int XGBoosterPredictFromDense(BoosterHandle handle, char const *values, char const *config,
1157  DMatrixHandle m, bst_ulong const **out_shape,
1158  bst_ulong *out_dim, const float **out_result);
1183 XGB_DLL int XGBoosterPredictFromColumnar(BoosterHandle handle, char const *values,
1184  char const *config, DMatrixHandle m,
1185  bst_ulong const **out_shape, bst_ulong *out_dim,
1186  const float **out_result);
1187 
1211 XGB_DLL int XGBoosterPredictFromCSR(BoosterHandle handle, char const *indptr, char const *indices,
1212  char const *values, bst_ulong ncol, char const *config,
1213  DMatrixHandle m, bst_ulong const **out_shape,
1214  bst_ulong *out_dim, const float **out_result);
1215 
1235 XGB_DLL int XGBoosterPredictFromCudaArray(BoosterHandle handle, char const *values,
1236  char const *config, DMatrixHandle proxy,
1237  bst_ulong const **out_shape, bst_ulong *out_dim,
1238  const float **out_result);
1239 
1260  char const *config, DMatrixHandle proxy,
1261  bst_ulong const **out_shape, bst_ulong *out_dim,
1262  const float **out_result);
1263  // End of Prediction
1265 
1266 
1302  const char *fname);
1311  const char *fname);
1321  const void *buf,
1322  bst_ulong len);
1323 
1340 XGB_DLL int XGBoosterSaveModelToBuffer(BoosterHandle handle, char const *config, bst_ulong *out_len,
1341  char const **out_dptr);
1342 
1353  const char **out_dptr);
1364  const void *buf, bst_ulong len);
1365 
1379  char const **out_str);
1389 XGB_DLL int XGBoosterLoadJsonConfig(BoosterHandle handle, char const *config); // End of Serialization
1391 
1402  const char *fmap,
1403  int with_stats,
1404  bst_ulong *out_len,
1405  const char ***out_dump_array);
1406 
1418  const char *fmap,
1419  int with_stats,
1420  const char *format,
1421  bst_ulong *out_len,
1422  const char ***out_dump_array);
1423 
1436  int fnum,
1437  const char **fname,
1438  const char **ftype,
1439  int with_stats,
1440  bst_ulong *out_len,
1441  const char ***out_models);
1442 
1456  int fnum,
1457  const char **fname,
1458  const char **ftype,
1459  int with_stats,
1460  const char *format,
1461  bst_ulong *out_len,
1462  const char ***out_models);
1463 
1473  const char* key,
1474  const char** out,
1475  int *success);
1486  const char* key,
1487  const char* value);
1496  bst_ulong* out_len,
1497  const char*** out);
1498 
1514 XGB_DLL int XGBoosterSetStrFeatureInfo(BoosterHandle handle, const char *field,
1515  const char **features,
1516  const bst_ulong size);
1517 
1537 XGB_DLL int XGBoosterGetStrFeatureInfo(BoosterHandle handle, const char *field,
1538  bst_ulong *len,
1539  const char ***out_features);
1540 
1566 XGB_DLL int XGBoosterFeatureScore(BoosterHandle handle, const char *config,
1567  bst_ulong *out_n_features, char const ***out_features,
1568  bst_ulong *out_dim, bst_ulong const **out_shape,
1569  float const **out_scores); // End of Booster
1571 
1609 typedef void *TrackerHandle; /* NOLINT */
1610 
1641 XGB_DLL int XGTrackerCreate(char const *config, TrackerHandle *handle);
1642 
1652 XGB_DLL int XGTrackerWorkerArgs(TrackerHandle handle, char const **args);
1653 
1663 XGB_DLL int XGTrackerRun(TrackerHandle handle, char const *config);
1664 
1675 XGB_DLL int XGTrackerWaitFor(TrackerHandle handle, char const *config);
1676 
1687 
1722 XGB_DLL int XGCommunicatorInit(char const* config);
1723 
1732 
1739 
1746 
1753 
1763 XGB_DLL int XGCommunicatorPrint(char const *message);
1764 
1771 XGB_DLL int XGCommunicatorGetProcessorName(const char** name_str);
1772 
1788 XGB_DLL int XGCommunicatorBroadcast(void *send_receive_buffer, size_t size, int root);
1789 
1811 XGB_DLL int XGCommunicatorAllreduce(void *send_receive_buffer, size_t count, int data_type, int op);
1812  // End of Collective
1814 #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:1609
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:345
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:391
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:377
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:445
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:343
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:450
int XGProxyDMatrixSetDataCudaArrayInterface(DMatrixHandle handle, const char *data)
Set data on a DMatrix proxy.
Mini batch used in XGBoost Data Iteration.
Definition: c_api.h:349
int64_t * offset
row pointer to the rows in the data
Definition: c_api.h:360
int * index
feature index
Definition: c_api.h:367
float * value
feature values
Definition: c_api.h:369
size_t columns
Definition: c_api.h:353
float * weight
weight of each instance, can be NULL
Definition: c_api.h:365
size_t size
number of rows in the minibatch
Definition: c_api.h:351