Learn R Programming

scorecardModelUtils (version 0.0.1.0)

fn_cross_index: Creates random index for k-fold cross validation

Description

The function base and returns a list of length k, to be used for k-fold cross validation sampling. Each element of the returned list is an array of random index for sampling for k-fold cross validation.

Usage

fn_cross_index(base, k)

Arguments

base

input dataframe

k

number of cross validation

Value

The function a list of length k, each holding an array of index/row number for sampling the base.

Examples

Run this code
# NOT RUN {
data <- iris
data$Species <- as.character(data$Species)
suppressWarnings(RNGversion('3.5.0'))
set.seed(11)
data$Y <- sample(0:1,size=nrow(data),replace=TRUE)
data$Y_pred <- sample(0:1,size=nrow(data),replace=TRUE)
data_k_list <- fn_cross_index(base = data,k = 5)
data_k_list$index1
data_k_list$index2
data_k_list$index3
data_k_list$index4
data_k_list$index5
# }

Run the code above in your browser using DataLab