Closed PathosEthosLogos closed 2 years ago
I believe this is possible via rsample::nested_cv()
, for instance (using the attached ex.csv
):
library(rsample)
library(spatialsample)
example <- read.csv("https://github.com/tidymodels/spatialsample/files/8984843/ex.csv")
x <- example |>
sliding_window(lookback = 1000)
pretty(x)
#> [1] "Sliding window resampling"
y <- example |>
spatial_clustering_cv(coords = c(x, y), v = 5)
y
#> # 5-fold spatial cross-validation
#> # A tibble: 5 × 2
#> splits id
#> <list> <chr>
#> 1 <split [8123/1877]> Fold1
#> 2 <split [8008/1992]> Fold2
#> 3 <split [8085/1915]> Fold3
#> 4 <split [7729/2271]> Fold4
#> 5 <split [8055/1945]> Fold5
xy <- example |>
nested_cv(
outside = spatial_clustering_cv(coords = c(x, y), v = 5),
inside = sliding_window(lookback = 1000)
)
pretty(xy)
#> [1] "Nested resampling:"
#> [2] " outer: 5-fold spatial cross-validation"
#> [3] " inner: Sliding window resampling"
Created on 2022-06-25 by the reprex package (v2.0.1)
Is this what you're thinking of?
I'm going to go ahead and close this out! If it turns out I missed something, please feel free to open a new issue with more information. Thank you so much for helping out!
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.
First, thank you for this library. This library has been tremendous help.
https://github.com/tidymodels/rsample/issues/64#issue-362961204
The paper cited in the link above discusses blocked CVs.
In the latest release (0,2), it seems that layered CVs is the direction.
https://rsample.tidymodels.org/reference/slide-resampling.html
I would like to discuss the plausibility/practicality of a request for a two-layer blocked resampling method, where it combines (for example) the functions of
rsample::sliding_window()
andspatialsample::spatial_clustering_cv()
. Ifsliding_window()
creates 10 CVs andspatial_clustering_cv()
creates 10 CVs, it would create a total of 100 CVs.Please let me know what you think!