kfold.idx {PDtoolkit} | R Documentation |
Indices for K-fold validation
Description
kfold.idx
provides indices for K-fold validation.
Usage
kfold.idx(target, k = 10, type, seed = 2191)
Arguments
target |
Binary target variable. |
k |
Number of folds. If |
type |
Sampling type. Possible options are |
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
suppressMessages(library(PDtoolkit))
data(loans)
#good-bad ratio
prop.table(table(loans$Creditability))
#random k-folds
kf.r <- kfold.idx(target = loans$Creditability, k = 5, type = "random", seed = 2191)
lapply(kf.r, function(x) prop.table(table(loans$Creditability[x[[2]]])))
#stratified k-folds
kf.s <- kfold.idx(target = loans$Creditability, k = 5, type = "stratified", seed = 2191)
lapply(kf.s, function(x) prop.table(table(loans$Creditability[x[[2]]])))
[Package PDtoolkit version 1.2.0 Index]