Export a model to Python or C++

The CatBoost model can be saved as standalone Python or C++ code. This solution simplifies the integration of resulting models to Python and C++ applications, allows to port models to architectures that are not directly supported by CatBoost (such as ARM) and allows advanced users to manually explore or edit the model parameters.

Choose the implementation for more details.

Depending on the output format the resulting file contains one of the following methods for applying the model:

Alert

  • Multiclassification models are not currently supported.

  • The apply_catboost_model method is inferior in performance compared to the native CatBoost application methods, especially on large models and datasets.

Python package

The following parameters can be set for the corresponding methods and are used when the model is saved:

Method

Parameters

format

Description

The output format of the model.

Set the value of this parameter to “python” or “cpp”.

Command-line version

The following command keys can be specified for the corresponding commands and are used when the model is trained:

Command catboost fit

Command keys

--model-format

Key description

A comma-separated list of output model formats.

Set the value of this key to “Python” or “CPP”.