tidymodels / rsample

Classes and functions to create and summarize resampling objects
https://rsample.tidymodels.org
Other
341 stars 66 forks source link

`sliding_*()`: Should `Total` reflect number of rows in analysis and assessment set combined? #480

Open hfrick opened 6 months ago

hfrick commented 6 months ago

Should total refer only to those observations used in analysis and assessment set?

library(rsample)
data("Chicago", package = "modeldata")

index <- vctrs::new_date(c(1, 3, 4, 7, 8, 9, 13, 15, 16, 17))
df <- tibble::tibble(x = 1:10, index = index)

sliding_window(df, lookback = 2, assess_stop = 2) |>
  get_rsplit(1)
#> <Analysis/Assess/Total>
#> <3/2/10>

sliding_index(df, index, lookback = 2, assess_stop = 2) |>
  get_rsplit(1)
#> <Analysis/Assess/Total>
#> <2/1/10>

sliding_period(
  Chicago,
  date,
  "year",
  lookback = 2,
  assess_stop = 1
) |> 
  get_rsplit(1)
#> <Analysis/Assess/Total>
#> <1074/366/5698>

Created on 2024-05-19 with reprex v2.1.0