Using models exported as Python code

Purpose
Apply the model in Python format. The method is available within the output Python file with the model description.
Restriction.
  • 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
ParameterPossible typesDescription
float_features
  • list of int
  • list of float

The list of numerical features.

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

The list of categorical features.

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])
Type of return value
numpy.array (identical to the CatBoost().predict(prediction_type='RawFormulaVal') method output)Train a model