Treelite
|
C API of treelite, used for interfacing with other languages. More...
#include <treelite/annotator.h>
#include <treelite/c_api.h>
#include <treelite/compiler.h>
#include <treelite/compiler_param.h>
#include <treelite/data.h>
#include <treelite/filesystem.h>
#include <treelite/frontend.h>
#include <treelite/math.h>
#include <dmlc/thread_local.h>
#include <memory>
#include <algorithm>
#include "./c_api_error.h"
Go to the source code of this file.
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... | |
int | TreeliteAnnotateBranch (ModelHandle model, DMatrixHandle dmat, int nthread, int verbose, AnnotationHandle *out) |
annotate branches in a given model using frequency patterns in the training data. More... | |
int | TreeliteAnnotationSave (AnnotationHandle handle, const char *path) |
save branch annotation to a JSON file More... | |
int | TreeliteAnnotationFree (AnnotationHandle handle) |
delete branch annotation from memory More... | |
int | TreeliteCompilerCreate (const char *name, CompilerHandle *out) |
create a compiler with a given name More... | |
int | TreeliteCompilerSetParam (CompilerHandle handle, const char *name, const char *value) |
set a parameter for a compiler More... | |
int | TreeliteCompilerGenerateCode (CompilerHandle compiler, ModelHandle model, int verbose, const char *dirpath) |
generate prediction code from a tree ensemble model. The code will be C99 compliant. One header file (.h) will be generated, along with one or more source files (.c). More... | |
int | TreeliteCompilerFree (CompilerHandle handle) |
delete compiler from memory More... | |
int | TreeliteLoadLightGBMModel (const char *filename, ModelHandle *out) |
load a model file generated by LightGBM (Microsoft/LightGBM). The model file must contain a decision tree ensemble. More... | |
int | TreeliteLoadXGBoostModel (const char *filename, ModelHandle *out) |
load a model file generated by XGBoost (dmlc/xgboost). The model file must contain a decision tree ensemble. More... | |
int | TreeliteLoadXGBoostModelFromMemoryBuffer (const void *buf, size_t len, ModelHandle *out) |
load an XGBoost model from a memory buffer. More... | |
int | TreeliteLoadProtobufModel (const char *filename, ModelHandle *out) |
load a model in Protocol Buffers format. Protocol Buffers (google/protobuf) is a language- and platform-neutral mechanism for serializing structured data. See tree.proto for format spec. More... | |
int | TreeliteExportProtobufModel (const char *filename, ModelHandle model) |
export a model in Protocol Buffers format. Protocol Buffers (google/protobuf) is a language- and platform-neutral mechanism for serializing structured data. See src/tree.proto for format spec. More... | |
int | TreeliteFreeModel (ModelHandle handle) |
delete model from memory More... | |
int | TreeliteQueryNumTree (ModelHandle handle, size_t *out) |
Query the number of trees in the model. More... | |
int | TreeliteQueryNumFeature (ModelHandle handle, size_t *out) |
Query the number of features used in the model. More... | |
int | TreeliteQueryNumOutputGroups (ModelHandle handle, size_t *out) |
Query the number of output groups of the model. More... | |
int | TreeliteSetTreeLimit (ModelHandle handle, size_t limit) |
keep first N trees of model, limit must smaller than number of trees. More... | |
int | TreeliteCreateTreeBuilder (TreeBuilderHandle *out) |
Create a new tree builder. More... | |
int | TreeliteDeleteTreeBuilder (TreeBuilderHandle handle) |
Delete a tree builder from memory. More... | |
int | TreeliteTreeBuilderCreateNode (TreeBuilderHandle handle, int node_key) |
Create an empty node within a tree. More... | |
int | TreeliteTreeBuilderDeleteNode (TreeBuilderHandle handle, int node_key) |
Remove a node from a tree. More... | |
int | TreeliteTreeBuilderSetRootNode (TreeBuilderHandle handle, int node_key) |
Set a node as the root of a tree. More... | |
int | TreeliteTreeBuilderSetNumericalTestNode (TreeBuilderHandle handle, int node_key, unsigned feature_id, const char *opname, float threshold, int default_left, int left_child_key, int right_child_key) |
Turn an empty node into a test node with numerical split. The test is in the form [feature value] OP [threshold]. Depending on the result of the test, either left or right child would be taken. More... | |
int | TreeliteTreeBuilderSetCategoricalTestNode (TreeBuilderHandle handle, int node_key, unsigned feature_id, const unsigned int *left_categories, size_t left_categories_len, int default_left, int left_child_key, int right_child_key) |
Turn an empty node into a test node with categorical split. A list defines all categories that would be classified as the left side. Categories are integers ranging from 0 to (n-1), where n is the number of categories in that particular feature. Let's assume n <= 64. More... | |
int | TreeliteTreeBuilderSetLeafNode (TreeBuilderHandle handle, int node_key, float leaf_value) |
Turn an empty node into a leaf node. More... | |
int | TreeliteTreeBuilderSetLeafVectorNode (TreeBuilderHandle handle, int node_key, const float *leaf_vector, size_t leaf_vector_len) |
Turn an empty node into a leaf vector node The leaf vector (collection of multiple leaf weights per leaf node) is useful for multi-class random forest classifier. More... | |
int | TreeliteCreateModelBuilder (int num_feature, int num_output_group, int random_forest_flag, ModelBuilderHandle *out) |
Create a new model builder. More... | |
int | TreeliteModelBuilderSetModelParam (ModelBuilderHandle handle, const char *name, const char *value) |
Set a model parameter. More... | |
int | TreeliteDeleteModelBuilder (ModelBuilderHandle handle) |
Delete a model builder from memory. More... | |
int | TreeliteModelBuilderInsertTree (ModelBuilderHandle handle, TreeBuilderHandle tree_builder_handle, int index) |
Insert a tree at specified location. More... | |
int | TreeliteModelBuilderGetTree (ModelBuilderHandle handle, int index, TreeBuilderHandle *out) |
Get a reference to a tree in the ensemble. More... | |
int | TreeliteModelBuilderDeleteTree (ModelBuilderHandle handle, int index) |
Remove a tree from the ensemble. More... | |
int | TreeliteModelBuilderCommitModel (ModelBuilderHandle handle, ModelHandle *out) |
finalize the model and produce the in-memory representation More... | |
C API of treelite, used for interfacing with other languages.
Copyright (c) 2017-2020 by Contributors
Definition in file c_api.cc.