Catboost 理解 - 分类值的转换

Catboost understanding - Conversion of Categorical values

我有一些关于 catboost 的愚蠢问题。

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

我试图根据单个观察结果进行预测以检查我的模型是否有效,但出现错误。然而,通过 2 个观察,它工作正常。

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

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

问题是在 predictfit 之前应用了相同的方法 catboost.Pool._check_data_empty。对于拟合来说,不止一次的观察确实是至关重要的。

现在检查功能需要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 之前添加一两个假行来取得很好的效果。它们不会影响原始行的输出。