Description Usage Arguments Details Value See Also Examples
kfold_grid
creates a k-fold partitioning of geographical data for
cross-validation based on spatial grid partitioning. Returns a vector with
fold numbers ranging from 1 to k.
1 | kfold_grid(data, k = 4, lonlat = TRUE)
|
data |
Matrix or dataframe. The first two columns should represent the
longitude and latitude (or x,y coordinates if |
k |
Integer. The number of folds (partitions) that have to be created. This should be a square number (e.g 4, 9, 16). By default 4 folds are created. |
lonlat |
Logical. If |
If lonlat = TRUE
then the data is first split along the
longitude based on a random starting point and then splitting in parts with
k/2 points
while crossing the dateline. Then each part is splitted
along quantiles of the latitude in each part.
A vector with fold numbers ranging from 1 to k.
plot_folds
, kfold_disc
,
kfold
, , kfold_occurrence_background
1 2 3 4 5 6 7 8 9 | set.seed(42)
lonlat_data <- cbind(runif(11, -180, 180), runif(11, -90, 90))
folds <- kfold_grid(lonlat_data, k = 4)
plot_folds(lonlat_data, folds)
# for x,y data
xy_data <- cbind(runif(11, 0, 100), runif(11, 0, 100))
folds <- kfold_grid(xy_data, k = 4, lonlat = FALSE)
plot_folds(xy_data, folds)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.