Catboost 正在进行交叉验证以确定最佳迭代次数。train_pool 和 test_pool 都是包含目标变量的数据集。在他们写的教程的前面
train_path = '../R-package/inst/extdata/adult_train.1000'
test_path = '../R-package/inst/extdata/adult_test.1000'
column_description_vector = rep('numeric', 15)
cat_features <- c(3, 5, 7, 8, 9, 10, 11, 15)
for (i in cat_features)
column_description_vector[i] <- 'factor'
train <- read.table(train_path, head=F, sep="\t", colClasses=column_description_vector)
test <- read.table(test_path, head=F, sep="\t", colClasses=column_description_vector)
target <- c(1)
train_pool <- catboost.from_data_frame(data=train[,-target], target=train[,target])
test_pool <- catboost.from_data_frame(data=test[,-target], target=test[,target])
当您执行 catboost.train(train_pool, test_pool, params_with_od) 时,train_pool 用于训练,而 test_pool 用于通过交叉验证确定最佳迭代次数。
现在你感到困惑是对的,因为在本教程的后面,他们再次使用 test_pool 和拟合模型进行预测(model_best 类似于 model_with_od,但使用不同的过拟合检测器 IncToDec):
prediction_best <- catboost.predict(model_best, test_pool, type = 'Probability')
这可能是不好的做法。现在他们可能会用他们的 IncToDec 过拟合检测器侥幸逃脱——我不熟悉它背后的数学原理——但是对于 Iter 类型的过拟合检测器,你需要有单独的训练、验证和测试数据集(如果你想成为在保存方面,对 IncToDec 过拟合检测器执行相同的操作)。然而,这只是一个展示功能的教程,所以我不会对他们已经如何使用哪些数据过于迂腐。
这里有一个关于过拟合检测器的更多细节的链接:
https ://tech.yandex.com/catboost/doc/dg/concepts/overfitting-detector-docpage/