S
S
sha2562019-02-17 09:38:11
Machine learning
sha256, 2019-02-17 09:38:11

How to use CatBoost model after sum_models?

Friends, hello everyone!
I understand the CatBoost library, I analyze the example with sum_models:

from catboost import CatBoostClassifier, Pool, sum_models
from catboost.datasets import amazon
import numpy as np
from sklearn.model_selection import train_test_split

train_df, _ = amazon()

y = train_df.ACTION
X = train_df.drop('ACTION', axis=1)

categorical_features_indices = np.where(X.dtypes != np.float)[0]

X_train, X_validation, y_train, y_validation = train_test_split(X, 
                                                                y, 
                                                                train_size=0.8, 
                                                                random_state=42)

train_pool = Pool(X_train, 
                  y_train, 
                  cat_features=categorical_features_indices)
validate_pool = Pool(X_validation, 
                     y_validation, 
                     cat_features=categorical_features_indices)

models = []
for i in range(5):
    model = CatBoostClassifier(iterations=100, 
                               random_seed=i)
    model.fit(train_pool, 
              eval_set=validate_pool)
    models.append(model)

models_avrg = sum_models(models, 
                         weights=[1.0/len(models)] * len(models))

Why models_avrg becomes catboost.core.CatBoost at 0x1c9000726a0 and loses predict_proba method?
How to convert to catboost.core.CatBoostClassifier at 0x1c90006a978 ?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question