Description Usage Arguments Value Author(s) See Also Examples
Special case of cross-validation where the fold are defined by the user. Data are partitioned according to values contained in cv
.
1 | trainind.cv(cv)
|
cv |
Vector containing the fold information |
Returns a list of training index.
David Enot dle@aber.ac.uk
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 30 31 32 33 34 | ## Load abr1
data(abr1)
## cl is the class of interest
cl <- factor(abr1$fact$class)
dat <- preproc(abr1$pos , y=cl, method=c("log10","TICnorm"),add=1)[,110:500]
## For illustration, we use sample replicates id to form the CV folds
re <- factor(abr1$fact$rep)
## Check representativity of cl in each fold
table(re,cl)
## Generate a trainind object using re
tr.idx <- trainind.cv(re)
pars <- valipars(sampling="cv", niter=1, nreps=5)
## for fold num. 1
## check sample indices and replicates ids in the training set
tmp <- tr.idx[[1]]
cl[tmp[[1]]];table(re[tmp[[1]]]) ## train idx
## and in the test set
cl[-tmp[[1]]];table(re[-tmp[[1]]]) ## test idx
## accuracy estimation with constrained CV
acc <- accest(dat, cl, pars = pars, clmeth = "nlda", tr.idx=tr.idx)
acc
## compare it with random CV
pars.rnd <- valipars(sampling="cv", niter=10, nreps=5)
tr.idx.rnd <- trainind(cl,pars.rnd)
acc.rnd <- accest(dat, cl, pars = pars.rnd, clmeth = "nlda", tr.idx=tr.idx.rnd)
## plot the histogram of the accuracies at each iteration
hist(acc.rnd$acc.iter)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.