Learn R Programming

HEMDAG (version 2.1.3)

stratified.cross.validation: Stratified cross validation

Description

Generate data for the stratified cross-validation

Usage

do.stratified.cv.data.single.class(examples, positives, kk = 5, seed = NULL)

do.stratified.cv.data.over.classes(labels, examples, kk = 5, seed = NULL)

Arguments

examples

indices or names of the examples. Can be either a vector of integers or a vector of names.

positives

vector of integers or vector of names. The indices (or names) refer to the indices (or names) of 'positive' examples

kk

number of folds (def=5)

seed

seed of the random generator (def=NULL). If is set to NULL no initialization is performed

labels

labels matrix. Rows are genes and columns are classes. Let's denote \(M\) the labels matrix. If \(M[i,j]=1\), means that the gene \(i\) is annotated with the class \(j\), otherwise \(M[i,j]=0\).

Value

do.stratified.cv.data.single.class returns a list with 2 two component:

  • fold.non.positives: a list with \(k\) components. Each component is a vector with the indices (or names) of the non-positive elements. Indices (or names) refer to row numbers (or names) of a data matrix.

  • fold.positives: a list with \(k\) components. Each component is a vector with the indices (or names) of the positive elements. Indices (or names) refer to row numbers (or names) of a data matrix.

do.stratified.cv.data.over.classes returns a list with \(n\) components, where \(n\) is the number of classes of the labels matrix. Each component \(n\) is in turn a list with \(k\) elements, where \(k\) is the number of folds. Each fold contains an equal amount of examples positives and negatives.

Examples

Run this code
# NOT RUN {
data(labels);
examples.index <- 1:nrow(L);
examples.name <- rownames(L);
positives <- which(L[,3]==1);
x <- do.stratified.cv.data.single.class(examples.index, positives, kk=5, seed=23);
y <- do.stratified.cv.data.single.class(examples.name, positives, kk=5, seed=23);
z <- do.stratified.cv.data.over.classes(L, examples.index, kk=5, seed=23);
k <- do.stratified.cv.data.over.classes(L, examples.name, kk=5, seed=23);
# }

Run the code above in your browser using DataLab