Description Usage Arguments Value Methods (by class) References Examples
Generate cross-validated leave-one-out or leave-p-out test/training pairs.
The function leave-p-out
generates leave-p-out test/training pairs,
while the function leave-one-out
convenience function for the
common case of leave-one-out cross-validation, p = 1
.
1 2 3 4 5 6 7 8 9 | crossv_lpo(data, p, ...)
## S3 method for class 'data.frame'
crossv_lpo(data, p = 1L, ...)
## S3 method for class 'grouped_df'
crossv_lpo(data, p = 1L, ...)
crossv_loo(data)
|
data |
A data frame or vector |
p |
The number of elements to include in the test set. |
... |
Passed to methods |
A data frame with n choose p rows and the following columns:
A list of resample
objects. Training sets.
A list of resample
objects. Test sets.
An integer vector of identifiers
data.frame
: Generate test/train sets by leaving rows of the data frame out.
grouped_df
: Generate test/train sets by leaving groups out.
Breiman, L., Friedman, J.H., Olshen, R.A. and Stone, C.J. (1984) Classification and Regression Trees. Wadsworth.
Burman, P. (1989) A comparative study of ordinary cross-validation, v-fold cross-validation and repeated learning-testing methods. Biometrika, 76, 503–514
Davison, A.C. and Hinkley, D.V. (1997) Bootstrap Methods and Their Application. Cambridge University Press.
Efron, B. (1986) How biased is the apparent error rate of a prediction rule? Journal of the American Statistical Association, 81, 461–470.
Stone, M. (1974) Cross-validation choice and assessment of statistical predictions (with Discussion). Journal of the Royal Statistical Society, B, 36, 111–147.
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Example originally from modelr::crossv_mc
library("purrr")
library("dplyr")
# LOO cross-validation
cv1 <- crossv_loo(mtcars)
models <- map(cv1$train, ~ lm(mpg ~ wt, data = .))
summary(map2_dbl(models, cv1$test, modelr::rmse))
# Leave-p-Out cross-validation with p = 2
cv2 <- crossv_lpo(mtcars, p = 2)
models <- map(cv2$train, ~ lm(mpg ~ wt, data = .))
summary(map2_dbl(models, cv2$test, modelr::rmse))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.