-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent LOO through vfold_cv() #527
Conversation
vfold_cv() throws an error, if used for leave-one-out cross-validation, refering to loo_cv() instead. Fixes tidymodels#440
@seb09 Thanks a bunch for the PR! I'm just dropping in quickly to say that I'm OOO until the week after next but will get to this after my return. |
Enjoy your time off 🙂 |
- use cli - thread call through - keep error for repeated CV
for symmetry with the lower bound for `v`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@seb09 rsample already has a function to check that v
is something sensible, check_v()
, so I've moved your check there. This means we now catch it in vfold_cv()
and clustering_cv()
.
R/vfold.R
Outdated
@@ -74,17 +76,20 @@ vfold_cv <- function(data, v = 10, repeats = 1, | |||
strata_check(strata, data) | |||
check_repeats(repeats) | |||
|
|||
if (isTRUE(v == nrow(data))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice defensive isTRUE()
👍
R/vfold.R
Outdated
#' @param v The number of partitions of the data set. Should be an integer | ||
#' smaller than `nrow(data)`. If you want to create a split for a leave-one-out | ||
#' cross-validation (`v = nrow(data)`), please use [loo_cv()] instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also require a few other things of v
, e.g. to be larger than 1 and don't mention it all here. We could move it to the Details section but I think it's okay to let users bump into the error for the edgecases so that we can keep their focus on more high-level aspects.
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue. |
vfold_cv() throws an error, if used for leave-one-out cross-validation, refering to loo_cv() instead. Fixes #440