Implementation of CAST::CreateSpaceTimeFolds().

Details

Using "class" is helpful in the case that data are clustered in space and are categorical. E.g This is the case for land cover classifications when training data come as training polygons. In this case the data should be split in a way that entire polygons are held back (spacevar="polygonID") but at the same time the distribution of classes should be similar in each fold (class="LUC").

References

Meyer H, Reudenbach C, Hengl T, Katurji M, Nauss T (2018). “Improving performance of spatio-temporal machine learning models using forward feature selection and target-oriented validation.” Environmental Modelling & Software, 101, 1--9. doi: 10.1016/j.envsoft.2017.12.001 , https://doi.org/10.1016%2Fj.envsoft.2017.12.001.

Super class

mlr3::Resampling -> ResamplingSptCVCstf

Public fields

space_var

character(1)
Column name identifying the spatial units.

time_var

character(1)
Column name identifying the temporal units.

class

character(1)
Column name identifying a class unit (e.g. land cover).

Active bindings

iters

integer(1)
Returns the number of resampling iterations, depending on the values stored in the param_set.

Methods

Public methods

Inherited methods

Method new()

Create a "Spacetime Folds" resampling instance.

Usage

ResamplingSptCVCstf$new(
  id = "sptcv_cstf",
  space_var = NULL,
  time_var = NULL,
  class = NULL
)

Arguments

id

character(1)
Identifier for the resampling strategy.

space_var

character(1)
Column name identifying the spatial units.

time_var

character(1)
Column name identifying the temporal units.

class

character(1)
Column name identifying a class unit (e.g. land cover).


Method instantiate()

Materializes fixed training and test splits for a given task.

Usage

ResamplingSptCVCstf$instantiate(task)

Arguments

task

Task
A task to instantiate.

space_var

[character]
Column name identifying the spatial units.

time_var

[character]
Column name identifying the temporal units.

class

[character]
Column name identifying a class unit (e.g. land cover).


Method clone()

The objects of this class are cloneable with this method.

Usage

ResamplingSptCVCstf$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3) task = tsk("cookfarm") # Instantiate Resampling rcv = rsmp("sptcv_cstf", folds = 5, time_var = "Date", space_var = "SOURCEID") rcv$instantiate(task) # Individual sets: rcv$train_set(1)
#> [1] 1 3 11 16 20 21 25 31 32 33 34 53 55 56 59 76 92 116 149 #> [20] 155 156 168 173 174 178 179 192 200 210 221 236 237 239 240 242 256 264 270 #> [39] 274 287 288 301 302 304 309 314 316 317 333 338 340 342 351 353 355 357 364 #> [58] 389 395 396 403 406 409 411 413 417 420 421 424 430 431 434 445 450 453 454 #> [77] 456 469 475 479 485 489 490
rcv$test_set(1)
#> [1] 82 117 122 134 139 140 160 164 171 203 222 223 228 253 415 429
# check that no obs are in both sets intersect(rcv$train_set(1), rcv$test_set(1)) # good!
#> integer(0)
# Internal storage: rcv$instance # table
#> $test #> $test[[1]] #> [1] 82 117 122 134 139 140 160 164 171 203 222 223 228 253 415 429 #> #> $test[[2]] #> [1] 19 30 79 109 130 151 167 209 261 319 365 387 394 462 473 #> #> $test[[3]] #> [1] 63 64 125 163 169 205 207 225 249 298 318 343 366 370 412 426 448 460 #> #> $test[[4]] #> [1] 2 42 48 87 110 114 127 142 147 170 181 219 230 268 289 311 376 378 379 #> [20] 384 386 392 443 481 484 #> #> $test[[5]] #> [1] 4 67 86 93 187 189 198 215 320 323 332 347 358 361 383 400 432 449 459 #> #> #> $train #> $train[[1]] #> [1] 1 3 11 16 20 21 25 31 32 33 34 53 55 56 59 76 92 116 149 #> [20] 155 156 168 173 174 178 179 192 200 210 221 236 237 239 240 242 256 264 270 #> [39] 274 287 288 301 302 304 309 314 316 317 333 338 340 342 351 353 355 357 364 #> [58] 389 395 396 403 406 409 411 413 417 420 421 424 430 431 434 445 450 453 454 #> [77] 456 469 475 479 485 489 490 #> #> $train[[2]] #> [1] 13 17 22 23 41 44 45 46 49 51 60 62 74 77 90 94 96 103 104 #> [20] 112 119 123 132 133 135 137 143 148 165 184 188 191 194 195 202 208 216 220 #> [39] 227 232 238 243 246 252 254 263 266 278 279 284 290 292 294 308 310 321 324 #> [58] 334 336 348 349 359 372 385 393 397 398 399 401 416 423 425 438 444 447 452 #> [77] 458 463 466 468 474 480 482 487 493 497 498 #> #> $train[[3]] #> [1] 5 24 36 37 38 52 57 58 61 68 69 72 73 85 89 95 99 108 111 #> [20] 121 124 128 129 131 136 138 150 152 154 157 161 162 172 175 177 185 201 206 #> [39] 211 213 217 224 226 229 233 235 248 273 276 277 283 285 297 305 307 312 313 #> [58] 326 341 346 368 371 374 380 382 388 390 402 405 408 419 437 467 470 476 478 #> [77] 483 491 494 #> #> $train[[4]] #> [1] 6 7 9 10 14 28 39 47 65 75 78 80 81 83 88 97 101 102 106 #> [20] 107 141 144 153 159 166 180 186 190 199 212 234 241 244 251 258 259 271 272 #> [39] 280 281 282 286 296 299 303 306 315 322 327 328 329 337 344 345 354 356 362 #> [58] 363 367 369 373 377 391 407 410 428 433 451 457 465 471 472 488 492 #> #> $train[[5]] #> [1] 8 12 15 18 26 27 29 35 40 43 50 54 66 70 71 84 91 98 100 #> [20] 105 113 115 118 120 126 145 146 158 176 182 183 193 196 197 204 214 218 231 #> [39] 245 247 250 255 257 260 262 265 267 269 275 291 293 295 300 325 330 331 335 #> [58] 339 350 352 360 375 381 404 414 418 422 427 435 436 439 440 441 442 446 455 #> [77] 461 464 477 486 495 496 499 500 #> #>