【发布时间】:2021-04-26 13:07:21
【问题描述】:
我使用这段代码来测试 CatBoostClassifier。
import numpy as np
from catboost import CatBoostClassifier, Pool
# initialize data
train_data = np.random.randint(0, 100, size=(100, 10))
train_labels = np.random.randint(0, 2, size=(100))
test_data = Pool(train_data, train_labels) #What is Pool?When to use Pool?
# test_data = np.random.randint(0,100, size=(20, 10)) #Usually we will use numpy array,will not use Pool
model = CatBoostClassifier(iterations=2,
depth=2,
learning_rate=1,
loss_function='Logloss',
verbose=True)
# train the model
model.fit(train_data, train_labels)
# make the prediction using the resulting model
preds_class = model.predict(test_data)
preds_proba = model.predict_proba(test_data)
print("class = ", preds_class)
print("proba = ", preds_proba)
关于Pool的描述是这样的:
CatBoost 中使用的池作为训练模型的数据结构。
我认为通常我们会使用 numpy 数组,不会使用 Pool。
例如我们使用:
test_data = np.random.randint(0,100, size=(20, 10))
我没有发现Pool的更多用法,所以我想知道我们什么时候会使用Pool而不是numpy数组?
【问题讨论】:
标签: python scikit-learn catboost