pub unsafe extern "C" fn LGBM_BoosterPredictSparseOutput(
handle: BoosterHandle,
indptr: *const c_void,
indptr_type: c_int,
indices: *const i32,
data: *const c_void,
data_type: c_int,
nindptr: i64,
nelem: i64,
num_col_or_row: i64,
predict_type: c_int,
start_iteration: c_int,
num_iteration: c_int,
parameter: *const c_char,
matrix_type: c_int,
out_len: *mut i64,
out_indptr: *mut *mut c_void,
out_indices: *mut *mut i32,
out_data: *mut *mut c_void,
) -> c_intExpand description
Make sparse prediction for a new dataset in CSR or CSC format. Currently only used for feature contributions.
Note: The outputs are pre-allocated, as they can vary for each invocation, but the shape should be the same:
- for feature contributions, the shape of sparse matrix will be
num_class * num_data * (num_feature + 1). The output indptr_type for the sparse matrix will be the same as the given input indptr_type. CallLGBM_BoosterFreePredictSparseto deallocate resources.
§Arguments
handle- Handle of boosterindptr- Pointer to row headers for CSR or column headers for CSCindptr_type- Type ofindptr, can beC_API_DTYPE_INT32orC_API_DTYPE_INT64indices- Pointer to column indices for CSR or row indices for CSCdata- Pointer to the data spacedata_type- Type ofdatapointer, can beC_API_DTYPE_FLOAT32orC_API_DTYPE_FLOAT64nindptr- Number of entries inindptrnelem- Number of nonzero elements in the matrixnum_col_or_row- Number of columns for CSR or number of rows for CSCpredict_type- What should be predicted, only feature contributions supported currently
C_API_PREDICT_CONTRIB: feature contributions (SHAP values)
start_iteration- Start index of the iteration to predictnum_iteration- Number of iterations for prediction, <= 0 means no limitparameter- Other parameters for prediction, e.g. early stopping for predictionmatrix_type- Type of matrix input and output, can beC_API_MATRIX_TYPE_CSRorC_API_MATRIX_TYPE_CSCout_len(direction out) - Length of output data and output indptr (pointer to an array with two entries where to write them)out_indptr(direction out) - Pointer to output row headers for CSR or column headers for CSCout_indices(direction out) - Pointer to sparse column indices for CSR or row indices for CSCout_data(direction out) - Pointer to sparse data space
§Returns
0 when succeed, -1 when failure happens