我做了10倍的CV。我想将每个折叠的结果(预测)保存到单独的excel文件中。到目前为止,通过使用这个编码write.csv(预测,' test1.csv'),它只保存最后的折叠结果。我该怎么办?
for(i in 1:10)
{
testIndexes <- which(folds==i,arr.ind=TRUE)
testData <- CAMPUR[testIndexes, ]
#print(testData)
#flush.console()
trainData <- CAMPUR[-testIndexes, ]
#print(trainData)
#flush.console()
model <- NaiveBayes(DIS~., data=trainData, usekernel=TRUE)
predictions <- predict(model, testData[,1:2])
write.csv(predictions, 'test1.csv')
print(predictions)
flush.console()
c=confusionMatrix(predictions$class, testData$DIS)
print(c)
flush.console()
}
由于