
Last chance! 50% off unlimited learning
Sale ends in
Create spatial, temporal or spatio-temporal Folds for cross validation
CreateSpacetimeFolds(x, spacevar = NA, timevar = NA, k = 10,
seed = sample(1:1000, 1))
data.frame containing spatio-temporal data
Character indicating which column of x identifies the spatial units (e.g. ID of weather stations)
Character indicating which column of x identifies the temporal units (e.g. the day of the year)
numeric. Number of folds. If spacevar or timevar is NA and a leave one location out or leave one time step out cv should be performed, set k to the number of unique spatial or temporal units.
numeric. See ?seed
A list that contains a list for model training and a list for model validation that can directly be used as "index" and "indexOut" in caret's trainControl function
Meyer, H., Reudenbach, C., Hengl, T., Katurji, M., Nau<U+00DF>, T. (2018): Improving performance of spatio-temporal machine learning models using forward feature selection and target-oriented validation. Environmental Modelling & Software 101: 1-9.
# NOT RUN {
library(GSIF)
data(cookfarm)
### Prepare for 10-fold Leave-Location-and-Time-Out cross validation
indices <- CreateSpacetimeFolds(cookfarm$readings,"SOURCEID","Date")
str(indices)
### Prepare for 10-fold Leave-Location-Out cross validation
indices <- CreateSpacetimeFolds(cookfarm$readings,spacevar="SOURCEID")
str(indices)
### Prepare for leave-One-Location-Out cross validation
indices <- CreateSpacetimeFolds(cookfarm$readings,spacevar="SOURCEID",
k=length(unique(cookfarm$readings$SOURCEID)))
str(indices)
# }
Run the code above in your browser using DataLab