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 .

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