@@ -348,8 +348,8 @@ test_that("Logistic validation with `fit_resamples`", {
348348
349349 skip_if_not_installed(" tune" , " 1.2.0" )
350350 expect_equal(
351- names(val_with_pred $ .predictions_cal [[1 ]]),
352- c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" )
351+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
352+ sort( c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" ) )
353353 )
354354 expect_equal(
355355 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -380,8 +380,8 @@ test_that("Isotonic classification validation with `fit_resamples`", {
380380
381381 skip_if_not_installed(" tune" , " 1.2.0" )
382382 expect_equal(
383- names(val_with_pred $ .predictions_cal [[1 ]]),
384- c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" )
383+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
384+ sort( c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" ) )
385385 )
386386 expect_equal(
387387 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -413,8 +413,8 @@ test_that("Bootstrapped isotonic classification validation with `fit_resamples`"
413413
414414 skip_if_not_installed(" tune" , " 1.2.0" )
415415 expect_equal(
416- names(val_with_pred $ .predictions_cal [[1 ]]),
417- c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" )
416+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
417+ sort( c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" ) )
418418 )
419419 expect_equal(
420420 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -446,8 +446,8 @@ test_that("Beta calibration validation with `fit_resamples`", {
446446
447447 skip_if_not_installed(" tune" , " 1.2.0" )
448448 expect_equal(
449- names(val_with_pred $ .predictions_cal [[1 ]]),
450- c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" )
449+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
450+ sort( c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" ) )
451451 )
452452 expect_equal(
453453 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -481,8 +481,8 @@ test_that("Multinomial calibration validation with `fit_resamples`", {
481481
482482 skip_if_not_installed(" tune" , " 1.2.0" )
483483 expect_equal(
484- names(val_with_pred $ .predictions_cal [[1 ]]),
485- c(" .pred_one" , " .pred_two" , " .pred_three" , " .row" , " outcome" , " .config" , " .pred_class" )
484+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
485+ sort( c(" .pred_one" , " .pred_two" , " .pred_three" , " .row" , " outcome" , " .config" , " .pred_class" ) )
486486 )
487487 expect_equal(
488488 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -513,8 +513,8 @@ test_that("Validation without calibration with `fit_resamples`", {
513513
514514 skip_if_not_installed(" tune" , " 1.2.0" )
515515 expect_equal(
516- names(val_with_pred $ .predictions_cal [[1 ]]),
517- c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" )
516+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
517+ sort( c(" .pred_class_1" , " .pred_class_2" , " .row" , " outcome" , " .config" , " .pred_class" ) )
518518 )
519519 expect_equal(
520520 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -548,8 +548,8 @@ test_that("Linear validation with `fit_resamples`", {
548548
549549 skip_if_not_installed(" tune" , " 1.2.0" )
550550 expect_equal(
551- names(val_with_pred $ .predictions_cal [[1 ]]),
552- c(" .pred" , " .row" , " outcome" , " .config" )
551+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
552+ sort( c(" .pred" , " .row" , " outcome" , " .config" ) )
553553 )
554554 expect_equal(
555555 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -621,8 +621,8 @@ test_that("Isotonic regression validation with `fit_resamples`", {
621621
622622 skip_if_not_installed(" tune" , " 1.2.0" )
623623 expect_equal(
624- names(val_with_pred $ .predictions_cal [[1 ]]),
625- c(" .pred" , " .row" , " outcome" , " .config" )
624+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
625+ sort( c(" .pred" , " .row" , " outcome" , " .config" ) )
626626 )
627627 expect_equal(
628628 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -657,8 +657,8 @@ test_that("Isotonic bootstrapped regression validation with `fit_resamples`", {
657657
658658 skip_if_not_installed(" tune" , " 1.2.0" )
659659 expect_equal(
660- names(val_with_pred $ .predictions_cal [[1 ]]),
661- c(" .pred" , " .row" , " outcome" , " .config" )
660+ sort( names(val_with_pred $ .predictions_cal [[1 ]]) ),
661+ sort( c(" .pred" , " .row" , " outcome" , " .config" ) )
662662 )
663663 expect_equal(
664664 purrr :: map_int(val_with_pred $ splits , ~ holdout_length(.x )),
@@ -670,7 +670,6 @@ test_that("Isotonic bootstrapped regression validation with `fit_resamples`", {
670670
671671# ------------------------------------------------------------------------------
672672
673-
674673test_that(" validation functions error with tune_results input" , {
675674 skip_if_not_installed(" modeldata" )
676675 skip_if_not_installed(" nnet" )
@@ -698,3 +697,27 @@ test_that("validation functions error with tune_results input", {
698697 cal_validate_none(testthat_cal_binary())
699698 )
700699})
700+
701+ # ------------------------------------------------------------------------------
702+
703+ test_that(" validation sets fail with better message" , {
704+ library(tune )
705+ set.seed(1 )
706+ mt_split <- rsample :: initial_validation_split(mtcars )
707+ mt_rset <- rsample :: validation_set(mt_split )
708+ mt_res <-
709+ parsnip :: linear_reg() | >
710+ fit_resamples(
711+ mpg ~ . ,
712+ resamples = mt_rset ,
713+ control = control_resamples(save_pred = TRUE )
714+ )
715+
716+ expect_snapshot(cal_validate_beta(mt_res ), error = TRUE )
717+ expect_snapshot(cal_validate_isotonic(mt_res ), error = TRUE )
718+ expect_snapshot(cal_validate_isotonic_boot(mt_res ), error = TRUE )
719+ expect_snapshot(cal_validate_linear(mt_res ), error = TRUE )
720+ expect_snapshot(cal_validate_logistic(mt_res ), error = TRUE )
721+ expect_snapshot(cal_validate_multinomial(mt_res ), error = TRUE )
722+ expect_snapshot(cal_validate_none(mt_res ), error = TRUE )
723+ })
0 commit comments