View source: R/09_KFOLD_INDICES.R.R
kfold.idx | R Documentation |
kfold.idx
provides indices for K-fold validation.
kfold.idx(target, k = 10, type, num.strata = 4, seed = 2191)
target |
Continuous target variable. |
k |
Number of folds. If |
type |
Sampling type. Possible options are |
num.strata |
Number of strata for |
seed |
Random seed needed for ensuring the result reproducibility. Default is 2191. |
The command kfold.idx
returns a list of k folds estimation and validation indices.
library(monobin)
library(LGDtoolkit)
data(lgd.ds.c)
#random k-folds
kf.r <- LGDtoolkit::kfold.idx(target = lgd.ds.c$lgd, k = 5,
type = "random", seed = 2211)
sapply(kf.r, function(x) c(mean(lgd.ds.c$lgd[x[[1]]]), mean(lgd.ds.c$lgd[x[[2]]])))
sapply(kf.r, function(x) length(x[[2]]))
#stratified k-folds
kf.s <- LGDtoolkit::kfold.idx(target = lgd.ds.c$lgd, k = 5,
type = "stratified", num.strata = 10, seed = 2211)
sapply(kf.s, function(x) c(mean(lgd.ds.c$lgd[x[[1]]]), mean(lgd.ds.c$lgd[x[[2]]])))
sapply(kf.s, function(x) length(x[[2]]))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.