kfold.idx {LGDtoolkit} | R Documentation |
Indices for K-fold validation
Description
kfold.idx
provides indices for K-fold validation.
Usage
kfold.idx(target, k = 10, type, num.strata = 4, seed = 2191)
Arguments
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. |
Value
The command kfold.idx
returns a list of k folds estimation and validation indices.
Examples
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]]))
[Package LGDtoolkit version 0.2.0 Index]