Skip to content

Commit

Permalink
rename potato set to calibration (closes #260)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Sep 24, 2024
1 parent 3848526 commit acf34db
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 26 deletions.
8 changes: 4 additions & 4 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ fit.workflow <- function(object, data, ..., control = control_workflow()) {
cli_abort("{.arg data} must be provided to fit a workflow.")
}

# If `potato` is not overwritten in the following `if` statement, then the
# If `calibration` is not overwritten in the following `if` statement, then the
# the postprocessor doesn't actually require training and the dataset
# passed to `.fit_post()` will have no effect.
potato <- data
calibration <- data
if (.should_inner_split(object)) {
inner_split <- make_inner_split(object, data)

data <- rsample::analysis(inner_split)
potato <- rsample::assessment(inner_split)
calibration <- rsample::assessment(inner_split)
}

workflow <- object
workflow <- .fit_pre(workflow, data)
workflow <- .fit_model(workflow, control)
if (has_postprocessor(workflow)) {
workflow <- .fit_post(workflow, potato)
workflow <- .fit_post(workflow, calibration)
}
workflow <- .fit_finalize(workflow)

Expand Down
6 changes: 3 additions & 3 deletions R/post-action-tailor.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
#' predictions. Predictions on data that a model was trained on likely follow
#' different distributions than predictions on unseen data; thus, workflows must
#' split up the supplied `data` into two training sets, where the first is used to
#' train the preprocessor and model and the second is passed to that trained
#' processor and model to generate predictions, which then form the training data
#' for the post-processor.
#' train the preprocessor and model and the second, called the "calibration set,"
#' is passed to that trained postprocessor and model to generate predictions,
#' which then form the training data for the postprocessor.
#'
#' The arguments `prop` and `method` parameterize how that data is split up.
#' `prop` determines the proportion of rows in `fit.workflow(data)` that are
Expand Down
11 changes: 2 additions & 9 deletions man/add_model.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/add_tailor.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/fit-workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/workflow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/testthat/test-fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ test_that("`make_inner_split()` works", {
add_model(parsnip::linear_reg()) %>%
add_tailor(tlr)

# defaults to 1/3 allotted to potato via `mc_split`s
# defaults to 1/3 allotted to calibration via `mc_split`s
inner_splt <- make_inner_split(wflow, data.frame(x = 1:36))
expect_s3_class(inner_splt, c("mc_split_inner", "mc_split"))
expect_equal(nrow(rsample::analysis(inner_splt)), 24)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-post-action-tailor.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ test_that("postprocessor fit aligns with manually fitted version (with calibrati
wf_post_fit <- fit(wflow_post, dat)

# ...verify predictions are the same as training the post-proc separately.
# note that this test naughtily re-predicts on the potato set.
# note that this test naughtily re-predicts on the calibration set.
wflow_simple_preds <- augment(wf_simple_fit, rsample::assessment(inner_split))
post_trained <- fit(post, wflow_simple_preds, y, .pred)
wflow_manual_preds <- predict(post_trained, wflow_simple_preds)
Expand Down Expand Up @@ -188,7 +188,7 @@ test_that("postprocessor fit uses correct data (with calibration, non-default `p
wf_post_fit <- fit(wflow_post, dat)

# ...verify predictions are the same as training the post-proc separately.
# note that this test naughtily re-predicts on the potato set.
# note that this test naughtily re-predicts on the calibration set.
wflow_simple_preds <- augment(wf_simple_fit, rsample::assessment(inner_split))
post_trained <- fit(post, wflow_simple_preds, y, .pred)
wflow_manual_preds <- predict(post_trained, wflow_simple_preds)
Expand Down

0 comments on commit acf34db

Please sign in to comment.