oopt = ani.options(interval = 2, nmax = 10)
cv.ani(main = "Demonstration of the k-fold Cross Validation", bty = "l")
# leave-one-out CV
cv.ani(x = runif(15), k = 15)
# save the animation in HTML pages
ani.options(ani.height = 400, ani.width = 600, interval = 2,
nmax = 10, title = "Demonstration of the k-fold Cross Validation",
description = "This is a naive demonstration for the k-fold cross
validation. The k rectangles in the plot denote the k folds of data.
Each time a fold will be used as the test set and the rest parts
as the training set.")
ani.start()
par(mar = c(3, 3, 1, 0.5), mgp = c(1.5, 0.5, 0), tcl = -0.3)
cv.ani(bty = "l")
ani.stop()
ani.options(oopt)
Run the code above in your browser using DataLab