vignettes/multiROC_3_cvo.R

## ----options, echo = FALSE, message = FALSE, warning = FALSE-------------
optDEF <- knitr::opts_chunk$get()
knitr::opts_chunk$set(collapse = FALSE, comment = "#>")

knitr::opts_chunk$set(fig.width = 6, fig.align = 'center')

## ----Load packages, include = FALSE, message = FALSE, warning = FALSE----
library(manyROC)

## ------------------------------------------------------------------------
library(manyROC)

## ------------------------------------------------------------------------
# clear()

# Make some data
DataSet1 <- data.frame(ID = rep(1:20, each = 2),
                       gr = gl(4, 10, labels = LETTERS[1:4]),
                       .row = 1:40)

# Set parameters
nFolds = 5

# Explore data
str(DataSet1)

# table(DataSet1[,c("gr","ID")])
# summary(DataSet1)

## ------------------------------------------------------------------------

set.seed(1)
cvo_create_folds(block_by = DataSet1$ID, k = nFolds)

## ------------------------------------------------------------------------
Folds1_a <- cvo_create_folds(data = DataSet1,
                             stratify_by = "gr",
                             block_by = "ID",
                             nFolds,
                             returnTrain = FALSE)
# str(Folds1_a)
cvo_test_bs(Folds1_a,
            stratify_by = "gr",
            block_by = "ID",
            data = DataSet1)


## ------------------------------------------------------------------------
Folds1_b <- cvo_create_folds(stratify_by = DataSet1$gr,
                             block_by = DataSet1$ID,
                             k = nFolds,
                             returnTrain = FALSE)
# str(Folds1_b)
cvo_test_bs(Folds1_b,
            stratify_by = "gr",
            block_by = "ID",
            data = DataSet1
)

## ------------------------------------------------------------------------
Folds1_c <- cvo_create_folds(stratify_by = DataSet1$gr,
                             k = nFolds,
                             returnTrain = FALSE)
# str(Folds1_c)
cvo_test_bs(Folds1_c, 
            stratify_by = "gr",
            block_by = "ID",
            data = DataSet1)

## ------------------------------------------------------------------------
Folds1_d <- cvo_create_folds(block_by = DataSet1$ID,
                             k = nFolds,
                             returnTrain = FALSE)
# str(Folds1_d)
cvo_test_bs(Folds1_d,
            stratify_by = "gr",
            block_by = "ID",
            DataSet1)
GegznaV/multiROC documentation built on Sept. 24, 2018, 8:17 p.m.