1

我对 catboost 有一些愚蠢的问题。

从 catboost 的文档中,我了解到行之间存在一些排列/洗牌,用于分类数据转换。(https://tech.yandex.com/catboost/doc/dg/concepts/algorithm-main-stages_cat- to-numberic-docpage/#algorithm-main-stages_cat-to-numberic )

我试图预测一次观察以检查我的模型是否有效,但出现错误。但是,通过 2 次观察,它可以正常工作。

我的问题是,对于 catboost 分类器的预测,由于排列,我们是否必须至少给出 2 个观察值?如果是,第一次观察对输出有影响吗?

4

1 回答 1

2

Catboost 确实有这样的限制。但是,它与排列无关,因为它们仅在拟合阶段应用。

catboost.Pool._check_data_empty问题是之前应用了相同的方法predict以及fit. 而对于拟合,拥有不止一个观察结果确实是至关重要的。

现在检查功能需要sum(x.shape)>2,这确实很奇怪。下面的代码说明了这个问题:

import catboost
import numpy as np
x_train3 = np.array([[1,2,3,], [2,3,4], [3,4,5]])
x_train1 = np.array([[1], [2], [3]])
y_train = np.array([1,2,3])
x_test3_2 = np.array([[4,5,6], [5,6,7]])
x_test3_1 = np.array([[4,5,6,]])
x_test1_2 = np.array([[4], [5]])
x_test1_1 = np.array([[4]])
model3 = catboost.CatBoostRegressor().fit(x_train3, y_train)
model1 = catboost.CatBoostRegressor().fit(x_train1, y_train)
print(model3.predict(x_test3_2)) # OK
print(model3.predict(x_test3_1)) # OK
print(model1.predict(x_test1_2)) # OK
print(model1.predict(x_test1_1)) # Throws an error!

现在,您可以通过在调用predict. 它们对原始行的输出没有影响。

于 2017-10-31T17:10:02.513 回答