---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.3
alternate:
  - https://catboost.ai/docs/en/concepts/c-plus-plus-api_applycatboostmodel.md
---
> **Documentation Index:** Fetch the complete configuration index at https://catboost.ai/docs/en/llms.txt

# C++

## Purpose

Apply the model in C++ format. The method is available within the output C++ file with the model description.

{% note info %}

- <!-- source: en/_includes/work_src/reusage-common-phrases/cplusplus_apply_catboost_model__performance.md -->
  The ApplyCatboostModel method is inferior in performance compared to the native CatBoost application methods, especially on large models and datasets.
  <!-- endsource: en/_includes/work_src/reusage-common-phrases/cplusplus_apply_catboost_model__performance.md -->

{% endnote %}


## Method call format

<!-- source: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-only-numeric-features.md -->
For datasets that contain only numerical features:
<!-- endsource: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-only-numeric-features.md -->


```cpp
double ApplyCatboostModel(const std::vector<float>& features);
```

<!-- source: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-both-numerical-and-categorical-features.md -->
For datasets that contain both numerical and categorical features:
<!-- endsource: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-both-numerical-and-categorical-features.md -->


```cpp
double ApplyCatboostModel(const std::vector<float>& floatFeatures, const std::vector<std::string>& catFeatures);
```

## Parameters

### features (floatFeatures)


<!-- source: en/_includes/work_src/reusage-common-phrases/float-features-desc.md -->
The list of numerical features.
<!-- endsource: en/_includes/work_src/reusage-common-phrases/float-features-desc.md -->

Possible types: float


### catFeatures


<!-- source: en/_includes/work_src/reusage-common-phrases/categorical-features-list.md -->
The list of categorical features.
<!-- endsource: en/_includes/work_src/reusage-common-phrases/categorical-features-list.md -->

Possible types: string




{% note info %}

<!-- source: en/_includes/work_src/reusage-common-phrases/numerical-and-categorical-features-start.md -->
Numerical and categorical features must be passed separately in the same order they appear in the train dataset.

For example, let's assume that the train dataset contains the following features:

- Numerical features: `f1`, `f3`
- Categorical features: `f2`, `f4`

In this case, the following code must be used to apply the model:
<!-- endsource: en/_includes/work_src/reusage-common-phrases/numerical-and-categorical-features-start.md -->


```python
ApplyCatboostModel({f1, f3}, {f2, f4})
```

{% endnote %}


## Type of return value

Prediction of the model for the object with given features.

The result is identical to the code below but does not require the library linking (`libcatboostmodel.<so|dll|dylib>` for Linux/macOS or `libcatboostmodel.dll` for Windows):
- <!-- source: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-only-numeric-features.md -->
  For datasets that contain only numerical features:
  <!-- endsource: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-only-numeric-features.md -->

    ```cpp
    #include <catboost/libs/model_interface/wrapped_calcer.h>
    double ApplyCatboostModel(const std::vector<float>& features) {
        ModelCalcerWrapper calcer("model.cbm");
        return calcer.Calc(features, {});
    }
    ```

- <!-- source: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-both-numerical-and-categorical-features.md -->
  For datasets that contain both numerical and categorical features:
  <!-- endsource: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-both-numerical-and-categorical-features.md -->

    ```cpp
    #include <catboost/libs/model_interface/wrapped_calcer.h>
    double ApplyCatboostModel(const std::vector<float>& floatFeatures, const std::vector<std::string>& catFeatures) {
        ModelCalcerWrapper calcer("model.cbm");
        return calcer.Calc(floatFeatures, catFeatures);
    }
    ```

## Compilers

- <!-- source: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-only-numeric-features.md -->
  For datasets that contain only numerical features:
  <!-- endsource: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-only-numeric-features.md -->

    C++11 with support of non-static data member initializers and extended initializer lists.

- <!-- source: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-both-numerical-and-categorical-features.md -->
  For datasets that contain both numerical and categorical features:
  <!-- endsource: en/_includes/work_src/reusage-common-phrases/for-datasets-that-contain-both-numerical-and-categorical-features.md -->

    C++14 compiler with aggregate member initialization support. Tested with the following compilers:
    - Clang++ 3.8
    - g++ 5.4.1 20160904
