如何在caret中为repeatedcv创建分层折叠?

在caret中为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")

为了平衡group1和group2,折叠索引的创建是基于”group”变量的。

然而,有没有办法在caret中为repeatedcv创建createFolds呢?这样我就可以为repeatedcv获得一个平衡的分割。我应该结合几个createFolds并运行trainControl吗?

trControl = trainControl(method = "cv", index = many_repeated_folds) 

谢谢!


回答:

createMultiFolds 可能是你感兴趣的。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注