partition_fold: Create the multi-label dataset from folds

Description Usage Arguments Value Examples

View source: R/sampling.R

Description

This is a simple way to use k-fold cross validation.

Usage

1
partition_fold(kfold, n, has.validation = FALSE)

Arguments

kfold

A kFoldPartition object obtained from use of the method create_kfold_partition.

n

The number of the fold to separated train and test subsets.

has.validation

Logical value that indicate if a validation dataset will be used. (Default: FALSE)

Value

A list contained train and test mldr dataset:

trainThe mldr dataset with train examples, that includes all examples except those that are in test and validation samples testThe mldr dataset with test examples, defined by the number of the fold validationOptionally, only if has.validation = TRUE. The mldr dataset with validation examples

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
folds <- create_kfold_partition(toyml, 10)

# Using the first partition
dataset <- partition_fold(folds, 1)
names(dataset)
## [1] "train" "test"

# All iterations
for (i in 1:10) {
   dataset <- partition_fold(folds, i)
   #dataset$train
   #dataset$test
}

# Using 3 folds validation
dataset <- partition_fold(folds, 3, TRUE)
# dataset$train, dataset$test, #dataset$validation

rivolli/utiml documentation built on June 1, 2021, 11:48 p.m.