treelite
Functions
Dmatrix

Functions

int TreeliteDMatrixCreateFromFile (const char *path, const char *format, int nthread, int verbose, DMatrixHandle *out)
 create DMatrix from a file More...
 
int TreeliteDMatrixCreateFromCSR (const float *data, const unsigned *col_ind, const size_t *row_ptr, size_t num_row, size_t num_col, DMatrixHandle *out)
 create DMatrix from a (in-memory) CSR matrix More...
 
int TreeliteDMatrixCreateFromMat (const float *data, size_t num_row, size_t num_col, float missing_value, DMatrixHandle *out)
 create DMatrix from a (in-memory) dense matrix More...
 
int TreeliteDMatrixGetDimension (DMatrixHandle handle, size_t *out_num_row, size_t *out_num_col, size_t *out_nelem)
 get dimensions of a DMatrix More...
 
int TreeliteDMatrixGetPreview (DMatrixHandle handle, const char **out_preview)
 produce a human-readable preview of a DMatrix Will print first and last 25 non-zero entries, along with their locations More...
 
int TreeliteDMatrixGetArrays (DMatrixHandle handle, const float **out_data, const uint32_t **out_col_ind, const size_t **out_row_ptr)
 extract three arrays (data, col_ind, row_ptr) that define a DMatrix. More...
 
int TreeliteDMatrixFree (DMatrixHandle handle)
 delete DMatrix from memory More...
 

Detailed Description

Data matrix interface

Function Documentation

◆ TreeliteDMatrixCreateFromCSR()

int TreeliteDMatrixCreateFromCSR ( const float *  data,
const unsigned *  col_ind,
const size_t *  row_ptr,
size_t  num_row,
size_t  num_col,
DMatrixHandle out 
)

create DMatrix from a (in-memory) CSR matrix

Parameters
datafeature values
col_indfeature indices
row_ptrpointer to row headers
num_rownumber of rows
num_colnumber of columns
outthe created DMatrix
Returns
0 for success, -1 for failure

Definition at line 59 of file c_api.cc.

◆ TreeliteDMatrixCreateFromFile()

int TreeliteDMatrixCreateFromFile ( const char *  path,
const char *  format,
int  nthread,
int  verbose,
DMatrixHandle out 
)

create DMatrix from a file

Parameters
pathfile path
formatfile format
nthreadnumber of threads to use
verbosewhether to produce extra messages
outthe created DMatrix
Returns
0 for success, -1 for failure

Definition at line 48 of file c_api.cc.

◆ TreeliteDMatrixCreateFromMat()

int TreeliteDMatrixCreateFromMat ( const float *  data,
size_t  num_row,
size_t  num_col,
float  missing_value,
DMatrixHandle out 
)

create DMatrix from a (in-memory) dense matrix

Parameters
datafeature values
num_rownumber of rows
num_colnumber of columns
missing_valuevalue to represent missing value
outthe created DMatrix
Returns
0 for success, -1 for failure

Definition at line 97 of file c_api.cc.

◆ TreeliteDMatrixFree()

int TreeliteDMatrixFree ( DMatrixHandle  handle)

delete DMatrix from memory

Parameters
handlehandle to DMatrix
Returns
0 for success, -1 for failure

Definition at line 197 of file c_api.cc.

◆ TreeliteDMatrixGetArrays()

int TreeliteDMatrixGetArrays ( DMatrixHandle  handle,
const float **  out_data,
const uint32_t **  out_col_ind,
const size_t **  out_row_ptr 
)

extract three arrays (data, col_ind, row_ptr) that define a DMatrix.

Parameters
handlehandle to DMatrix
out_dataused to save pointer to array containing feature values
out_col_indused to save pointer to array containing feature indices
out_row_ptrused to save pointer to array containing pointers to row headers
Returns
0 for success, -1 for failure

Definition at line 185 of file c_api.cc.

◆ TreeliteDMatrixGetDimension()

int TreeliteDMatrixGetDimension ( DMatrixHandle  handle,
size_t *  out_num_row,
size_t *  out_num_col,
size_t *  out_nelem 
)

get dimensions of a DMatrix

Parameters
handlehandle to DMatrix
out_num_rowused to set number of rows
out_num_colused to set number of columns
out_nelemused to set number of nonzero entries
Returns
0 for success, -1 for failure

Definition at line 144 of file c_api.cc.

◆ TreeliteDMatrixGetPreview()

int TreeliteDMatrixGetPreview ( DMatrixHandle  handle,
const char **  out_preview 
)

produce a human-readable preview of a DMatrix Will print first and last 25 non-zero entries, along with their locations

Parameters
handlehandle to DMatrix
out_previewused to save the address of the string literal
Returns
0 for success, -1 for failure

Definition at line 156 of file c_api.cc.