Python

Purpose

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

Alert

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

  • Multiclassification models are not currently supported.

Dependencies

CityHash v.1 library. The correct version is also available in the CatBoost repository.

Method call format

For datasets that contain only numerical features:

apply_catboost_model(float_features)

For datasets that contain both numerical and categorical features:

apply_catboost_model(float_features,
                     cat_features)

Parameters

float_features

The list of numerical features.

Possible types:

  • list of int
  • list of float

cat_features

The list of categorical features.

Possible types:

  • list of int
  • list of float
  • list of strings

Note

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:

apply_catboost_model(float_features=[f1,f3],
                     cat_features=[f2,f4])

--model-format key of the command-line train mode

Type of return value

numpy.ndarray (identical to the [CatBoost()](python-reference_catboost.md).[predict](python-reference_catboost_predict.md)(prediction_type='RawFormulaVal') method output)Train a model

Previous