Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions tests/testthat/helper-postprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ if (rlang::is_installed("probably")) {
reg_cal <- tailor::tailor() |>
tailor::adjust_numeric_calibration()

reg_cal_tune <- tailor::tailor() |>
tailor::adjust_numeric_calibration(method = tune())

reg_max <- tailor::tailor() |>
tailor::adjust_numeric_range(upper_limit = tune())
}
Expand Down
32 changes: 16 additions & 16 deletions tests/testthat/test-loop-over-all-stages-row-wise.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test_that("convert grid to rowwise - submodels", {
skip_if_not_installed("probably")

# Model only
wflow_1 <- workflow(Class ~ ., glmn_spec, cls_est_post)
wflow_1 <- workflow(Class ~ ., glmn_spec, reg_cal)
param_1 <- wflow_1 |> extract_parameter_set_dials()

grid_reg_1 <- grid_regular(param_1) |> arrange(mixture, penalty)
Expand All @@ -107,7 +107,7 @@ test_that("convert grid to rowwise - submodels", {
}

# Recipe + Model
wflow_2 <- workflow(puromycin_tune_rec, glmn_spec, cls_est_post)
wflow_2 <- workflow(puromycin_tune_rec, glmn_spec, reg_cal)
param_2 <- wflow_2 |> extract_parameter_set_dials()

grid_reg_2 <- grid_regular(param_2)
Expand All @@ -133,54 +133,54 @@ test_that("convert grid to rowwise - submodels", {
}

# Model + Post
wflow_3 <- workflow(Class ~ ., glmn_spec, cls_post)
wflow_3 <- workflow(Class ~ ., glmn_spec, reg_cal_tune)
param_3 <- wflow_3 |> extract_parameter_set_dials()

grid_reg_3 <- grid_regular(param_3)
distinct_reg_3 <- distinct(grid_reg_3, cut, mixture) |>
arrange(mixture, cut)
distinct_reg_3 <- distinct(grid_reg_3, method, mixture) |>
arrange(mixture, method)

res_reg_3 <- tune:::get_row_wise_grid(wflow_3, grid_reg_3)
for (i in 1:nrow(distinct_reg_3)) {
sub <- grid_reg_3 |>
inner_join(distinct_reg_3[i, ], by = c("mixture", "cut"))
inner_join(distinct_reg_3[i, ], by = c("mixture", "method"))
expect_equal(res_reg_3[[i]], sub)
}

grid_sfd_3 <- grid_space_filling(param_3)
distinct_sfd_3 <- distinct(grid_sfd_3, cut, mixture) |>
arrange(mixture, cut)
distinct_sfd_3 <- distinct(grid_sfd_3, method, mixture) |>
arrange(mixture, method)

res_sfd_3 <- tune:::get_row_wise_grid(wflow_3, grid_sfd_3)
for (i in 1:nrow(distinct_sfd_3)) {
sub <- grid_sfd_3 |>
inner_join(distinct_sfd_3[i, ], by = c("mixture", "cut"))
inner_join(distinct_sfd_3[i, ], by = c("mixture", "method"))
expect_equal(res_sfd_3[[i]], sub)
}

# Recipe + Model + Post
wflow_4 <- workflow(puromycin_tune_rec, glmn_spec, cls_post)
wflow_4 <- workflow(puromycin_tune_rec, glmn_spec, reg_cal_tune)
param_4 <- wflow_4 |> extract_parameter_set_dials()

grid_reg_4 <- grid_regular(param_4)
distinct_reg_4 <- distinct(grid_reg_4, degree, cut, mixture) |>
arrange(mixture, degree, cut)
distinct_reg_4 <- distinct(grid_reg_4, degree, method, mixture) |>
arrange(mixture, degree, method)

res_reg_4 <- tune:::get_row_wise_grid(wflow_4, grid_reg_4)
for (i in 1:nrow(distinct_reg_4)) {
sub <- grid_reg_4 |>
inner_join(distinct_reg_4[i, ], by = c("mixture", "degree", "cut"))
inner_join(distinct_reg_4[i, ], by = c("mixture", "degree", "method"))
expect_equal(res_reg_4[[i]], sub)
}

grid_sfd_4 <- grid_space_filling(param_4)
distinct_sfd_4 <- distinct(grid_sfd_4, degree, cut, mixture) |>
arrange(mixture, degree, cut)
distinct_sfd_4 <- distinct(grid_sfd_4, degree, method, mixture) |>
arrange(mixture, degree, method)

res_sfd_4 <- tune:::get_row_wise_grid(wflow_4, grid_sfd_4)
for (i in 1:nrow(distinct_sfd_4)) {
sub <- grid_sfd_4 |>
inner_join(distinct_sfd_4[i, ], by = c("mixture", "degree", "cut"))
inner_join(distinct_sfd_4[i, ], by = c("mixture", "degree", "method"))
expect_equal(res_sfd_4[[i]], sub)
}
})
8 changes: 4 additions & 4 deletions tests/testthat/test-schedule.R
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ test_that("grid processing schedule - recipe, model, and post", {
skip_if_not_installed("splines2")
skip_if_not_installed("probably")

wflow_three <- workflow(rec_no_tune, parsnip::logistic_reg(), tlr_no_tune)
wflow_three <- workflow(rec_no_tune, parsnip::linear_reg(), tlr_no_tune)
grid_three <- tibble::tibble()
sched_three <- schedule_grid(grid_three, wflow_three)

Expand Down Expand Up @@ -733,7 +733,7 @@ test_that("grid processing schedule - model only, submodels, 1 point design", {
test_that("grid processing schedule - postprocessing only", {
skip_if_not_installed("probably")

wflow_thrsh <- workflow(outcome ~ ., parsnip::logistic_reg(), tlr_tune)
wflow_thrsh <- workflow(outcome ~ ., parsnip::linear_reg(), tlr_tune)
grid_thrsh <- extract_parameter_set_dials(wflow_thrsh) |>
update(lower_limit = dials::lower_limit(c(0, 1))) |>
dials::grid_regular(levels = 3)
Expand Down Expand Up @@ -767,7 +767,7 @@ test_that("grid processing schedule - recipe + postprocessing, regular grid", {
skip_if_not_installed("splines2")
skip_if_not_installed("probably")

wflow_pre_post <- workflow(rec_tune, parsnip::logistic_reg(), tlr_tune)
wflow_pre_post <- workflow(rec_tune, parsnip::linear_reg(), tlr_tune)
grid_pre_post <-
extract_parameter_set_dials(wflow_pre_post) |>
update(lower_limit = dials::lower_limit(c(0, 1))) |>
Expand Down Expand Up @@ -816,7 +816,7 @@ test_that("grid processing schedule - recipe + postprocessing, irregular grid",
skip_if_not_installed("splines2")
skip_if_not_installed("probably")

wflow_pre_post <- workflow(rec_tune, parsnip::logistic_reg(), tlr_tune)
wflow_pre_post <- workflow(rec_tune, parsnip::linear_reg(), tlr_tune)
grid_pre_post <-
extract_parameter_set_dials(wflow_pre_post) |>
update(lower_limit = dials::lower_limit(c(0, 1))) |>
Expand Down
Loading