to_classifier
Purpose
Convert a model of type CatBoost to a model of type CatBoostClassifier. The model can be converted if the loss function of the source model is compatible with the one of the resulting model.
Method call format
to_classifier(model)
Parameters
model
Description
The input CatBoost model for convert.
Possible types
catboost.core.CatBoost
Default value
Obligatory parameter
Type of return value
catboost.core.CatBoostClassifier
Example
from catboost import Pool, to_classifier, CatBoost
train_data = [[0, 3],
[4, 1],
[8, 1],
[9, 1]]
train_labels = [0, 0, 1, 1]
model = CatBoost(params={'loss_function': 'Logloss'})
model.fit(train_data,
train_labels,
verbose=False)
print("Source model type: ", type(model))
converted_model = to_classifier(model)
print("Converted model type: ", type(converted_model))
The output of this example:
('Source model type: ', <class 'catboost.core.CatBoost'>)
('Converted model type: ', <class 'catboost.core.CatBoostClassifier'>)