getTrainingFolds: Create patient-independent folds in cross-validation in...

Description Usage Arguments Details Value See Also Examples

Description

Create patient-independent folds in cross-validation in training partition.

Usage

1
getTrainingFolds(trainEvents, folds, seed, verbose)

Arguments

trainEvents

a dataframe holding the event data ready for logit modeling, where each row is an event/clinical visit and the columns contain features of the event and the labels. It must contain an id column in the form "patientID.eventID".

folds

number of folds

seed

int, seed for split

verbose

logical, True for print, False for silence

Details

Patients in validation folds will not have events in training folds and vice versa.

Value

folds a list of arrays indicating row position integers corresponding to fold split

See Also

groupKFold, getPatIDs, getClassLabels, getData

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# use training partition to create folds for CV
data("features_ratechange_sup0.4g60l2z2") # features and labels for each clinical visit
t <- 'rate'
maxgap <- 60
maxlen <- 2
names <- colnames(feats)
feats <- data.frame(id=row.names(feats),feats)
colnames(feats) <- c('id',names)
feats <- prepLaterality(feats)
feats <- prepLocation(feats)
feats <- removeVisits(feats,
                     maxgap=maxgap,
                     maxlength=maxlen,
                     tType=t,
                     save=F,
                     outDir=NA)
labels <- getClassLabels()
needToRemove <- c('id','iois','eventID', # remove ids
                  labels, # remove labels
                  'IDH1') # not interested

# data partitions
train.ids <- sample(feats$id, size=floor(0.80*nrow(feats)), replace = F) # random
feats <- feats[feats$id %in% train.ids,] #training data
ind <- getTrainingFolds(trainEvents=feats,
                        folds=5,
                        seed=1,
                        verbose=T)
                        

novasmedley/gbmSpm documentation built on May 17, 2019, 10:39 a.m.