Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Machine learning 如何在插入符号中为repeatedcv创建分层褶皱?_Machine Learning_R Caret_Cross Validation - Fatal编程技术网

Machine learning 如何在插入符号中为repeatedcv创建分层褶皱?

Machine learning 如何在插入符号中为repeatedcv创建分层褶皱?,machine-learning,r-caret,cross-validation,Machine Learning,R Caret,Cross Validation,在插入符号中为cv创建分层褶皱的方法如下 library(caret) library(data.table) train_dat <- data.table(group = c(rep("group1",10), rep("group2",5)), x1 = rnorm(15), x2 = rnorm(15), label = factor(c(rep("treatment",15), rep("control",15)))) folds <- createFolds(train

在插入符号中为cv创建分层褶皱的方法如下

library(caret)
library(data.table)
train_dat <- data.table(group = c(rep("group1",10), rep("group2",5)), x1 = rnorm(15), x2 = rnorm(15), label = factor(c(rep("treatment",15), rep("control",15))))

folds <- createFolds(train_dat[, group], k = 5)

fitCtrl <- trainControl(method = "cv", index = folds, classProbs = T, summaryFunction = twoClassSummary)
train(label~., data = train_dat[, !c("group"), with = F], trControl = fitCtrl, method = "xgbTree", metric = "ROC")

谢谢

createMultiFolds
可能是您感兴趣的内容

createMultiFolds
可能是您感兴趣的内容

我投票结束这个问题,因为它是关于如何在没有可复制的例子的情况下使用R。谢谢你的评论@gungI添加了一个可复制的示例。你觉得怎么样@gungI投票结束这个问题,因为它是关于如何在没有可复制示例的情况下使用R。谢谢你的评论@gungI添加了一个可复制的示例。你觉得怎么样@冈吉,我不明白这个函数如何处理“分层”嗨,我不明白这个函数如何处理“分层”
trControl = trainControl(method = "cv", index = many_repeated_folds)