出于特定原因,您的数据是否被划分为这10个分区?如果不是,您可以再次将它们连接/混洗,然后进行常规(重复)交叉验证以执行参数网格搜索 . 例如,使用10个分区和10个重复可以提供总共100个训练和评估集 . 这些现在用于训练和评估所有参数集,因此您将尝试 100 results per parameter set . average performance per parameter set 可以从每组100个结果中计算出来 .
这个过程已经内置在大多数ML工具中,就像R中的这个简短示例一样,使用 caret 库:
library(caret)
library(lattice)
library(doMC)
registerDoMC(3)
model <- train(x = iris[,1:4],
y = iris[,5],
method = 'svmRadial',
preProcess = c('center', 'scale'),
tuneGrid = expand.grid(C=3**(-3:3), sigma=3**(-3:3)), # all permutations of these parameters get evaluated
trControl = trainControl(method = 'repeatedcv',
number = 10,
repeats = 10,
returnResamp = 'all', # store results of all parameter sets on all partitions and repeats
allowParallel = T))
# performance of different parameter set (e.g. average and standard deviation of performance)
print(model$results)
# visualization of the above
levelplot(x = Accuracy~C*sigma, data = model$results, col.regions=gray(100:0/100), scales=list(log=3))
# results of all parameter sets over all partitions and repeats. From this the metrics above get calculated
str(model$resample)
1 回答
出于特定原因,您的数据是否被划分为这10个分区?如果不是,您可以再次将它们连接/混洗,然后进行常规(重复)交叉验证以执行参数网格搜索 . 例如,使用10个分区和10个重复可以提供总共100个训练和评估集 . 这些现在用于训练和评估所有参数集,因此您将尝试 100 results per parameter set . average performance per parameter set 可以从每组100个结果中计算出来 .
这个过程已经内置在大多数ML工具中,就像R中的这个简短示例一样,使用
caret
库:一旦评估了超参数网格,就可以选择合理的参数集(“模型选择”,例如通过选择表现良好而仍然合理的非复杂模型) .
顺便说一句:如果可能的话,我会建议重复交叉验证而不是交叉验证(最终使用超过10次重复,但细节取决于你的问题);正如@ christian-cerri已经建议的那样,有一个额外的,看不见的测试集用于估计最终模型在新数据上的性能是一个好主意 .