@@ -9,14 +9,26 @@ test_that("forecast_holdout basic properties", {
99 expect_error(resampling $ train_set(2L ))
1010 expect_error(resampling $ test_set(2L ))
1111 expect_false(resampling $ duplicated_ids )
12+
13+ resampling = rsmp(" forecast_holdout" , ratio = 0.5 )$ instantiate(task )
14+ expect_length(resampling $ train_set(1L ), task $ nrow / 2 )
15+ expect_length(resampling $ test_set(1L ), task $ nrow / 2 )
16+
17+ resampling = rsmp(" forecast_holdout" , n = 10L )$ instantiate(task )
18+ expect_length(resampling $ train_set(1L ), 10L )
19+ expect_length(resampling $ test_set(1L ), task $ nrow - 10L )
20+
21+ resampling = rsmp(" forecast_holdout" , n = - 10L )$ instantiate(task )
22+ expect_length(resampling $ train_set(1L ), task $ nrow - 10L )
23+ expect_length(resampling $ test_set(1L ), 10L )
1224})
1325
1426test_that(" forecast_holdout works" , {
1527 skip_if_not_installed(" tsbox" )
1628 dt = tsbox :: ts_dt(AirPassengers )
1729 dt [, time : = NULL ]
1830 task = as_task_regr(dt , target = " value" )
19- resampling = rsmp(" forecast_holdout" )
31+ resampling = rsmp(" forecast_holdout" , ratio = 0.8 )
2032 resampling $ instantiate(task )
2133 expect_identical(resampling $ train_set(1L ), 1 : 115 )
2234 expect_identical(resampling $ test_set(1L ), 116 : 144 )
0 commit comments