to_regressor

Purpose

Convert a model of type CatBoost to a model of type CatBoostRegressor. 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_regressor(model)

Parameters

Parameter Type Description Default value
model catboost.core.CatBoost

The input CatBoost model for convert.

Obligatory parameter
Parameter Type Description Default value
model catboost.core.CatBoost

The input CatBoost model for convert.

Obligatory parameter

Type of return value

catboost.core.CatBoostRegressor

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.CatBoostRegressor'>)