tidymodels / spatialsample

Create and summarize spatial resampling objects 🗺
https://spatialsample.tidymodels.org
Other
71 stars 5 forks source link

We could signal silly grids better #67

Closed mikemahoney218 closed 2 years ago

mikemahoney218 commented 2 years ago

The problem

It's a little too easy right now to create silly grids. For instance, using our Boston data set:

library(spatialsample)
x <- spatial_block_cv(boston_canopy, n = c(200, 200), v = Inf)
#> Warning in spatial_block_cv(boston_canopy, n = c(200, 200), v = Inf): Fewer than Inf blocks available for sampling
#> ℹ Setting `v` to 682
autoplot(x) + ggplot2::theme(legend.position = "none")
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.

This grid is obviously mis-matched to the data, since 98% of blocks are getting thrown out. However, it's not wild to think that sometimes you expect the majority of blocks to get thrown away; for instance when blocking with island data:

boston_canopy[grep("^(A-|B|C|D|E|F|G|AQ|AP|AO|AN|AN|AL)", boston_canopy$grid_id), ] |> 
  spatial_block_cv() |> 
  autoplot()
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.

Created on 2022-06-14 by the reprex package (v2.0.1)

It'd be nice to have some messaging around this situation. Two possibilities:

juliasilge commented 2 years ago

There is already some infrastructure for silencing rlang::inform() messages, so if we use the first option we could point folks there to silence them, if they prefer. You can see how I point this out for vetiver here: https://rstudio.github.io/vetiver-r/articles/model-card.html

mikemahoney218 commented 2 years ago

We're going to go ahead and use rlang::inform() (and possibly sub-class the message so it can be silenced via options)

github-actions[bot] commented 2 years ago

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.