Evaluation library

This is the fastest way to evaluate a model. The library provides a C API and a simple C++ wrapper API. The C API interface can be accessed from any programming language.

Perform the following steps to build the library:
  1. Clone the repository:

    git clone https://github.com/catboost/catboost.git
  2. Open the catboost directory from the local copy of the CatBoost repository.

  3. Choose the preferred way to use the evaluation library and compile it accordingly:

    ya make -r catboost/libs/model_interface

    Or (Linux-only):

    export CXX=/path/to/clang++
    export CC=/path/to/clang
    make -f make/model_interface.CLANG50-LINUX-X86_64.makefile

    The output directory for the shared library (libcatboostmodel.<so|dll|dylib> for Linux/macOS or libcatboostmodel.dll for Windows) is catboost/libs/model_interface.

The CatBoost model can be loaded from a file or initialized from the buffer memory.


Perform the following steps to use this API:
  1. Link the required library (libcatboostmodel.<so|dll|dylib> for Linux/macOS or libcatboostmodel.dll for Windows).
  2. Use the methods from the model_calcer_wrapper.h file (refer to the doxygen-style documentation for details).
Sample C code without include statements:
float floatFeatures[100];
char* catFeatures[2] = {"1", "2"};
double result[1];
ModelCalcerHandle modelHandle;
modelHandle = ModelCalcerCreate();
if (!LoadFullModelFromFile(modelHandle, "model.cbm")) {
    printf("LoadFullModelFromFile error message: %s\n", GetErrorString());
if (!CalcModelPrediction(
        &floatFeatures, 100,
        &catFeatures, 2,
        &result, 1
    )) {
    printf("CalcModelPrediction error message: %s\n", GetErrorString());

C++ wrapper API

A C++ wrapper for the C API interface is also available.

Refer to the wrapped_calcer.h file and the sample CMake project in the CatBoost repository for more details.

Usage example:
ModelCalcerWrapper calcer("model.cbm");
std::vector<float> floatFeatures(100);
std::vector<std::string> catFeatures = {"one", "two", "three"};
std::cout << calcer.Calc(floatFeatures, catFeatures) << std::endl;

ModelCalcerWrapper also has a constructor to read data from the memory buffer.