Description Usage Arguments Value See Also Examples
kfold_disc
creates a k-fold partitioning of geographical data for
cross-validation based on the distance between points. The n points nearest
to a selected point are put into a group. Returns a vector with fold numbers
ranging from 1 to k.
1 | kfold_disc(data, k = 5, 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. By default 5 folds are created. |
lonlat |
Logical. If |
A vector with fold numbers ranging from 1 to k.
plot_folds
, kfold_grid
,
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_disc(lonlat_data, k = 5)
plot_folds(lonlat_data, folds)
# use the euclidean distance
xy_data <- cbind(runif(11, 0, 100), runif(11, 0, 100))
folds <- kfold_disc(xy_data, k = 5, 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.