Skip to contents

Splits data by clustering in the coordinate space. See the upstream implementation at sperrorest::partition_kmeans() and Brenning (2012) for further information.

Details

Universal partitioning method that splits the data in the coordinate space. Useful for spatially homogeneous datasets that cannot be split well with rectangular approaches like ResamplingSpCVBlock.

Parameters

  • folds (integer(1))
    Number of folds.

References

Brenning A (2012). “Spatial cross-validation and bootstrap for the assessment of prediction rules in remote sensing: The R package sperrorest.” In 2012 IEEE International Geoscience and Remote Sensing Symposium. doi:10.1109/igarss.2012.6352393 .

Super class

mlr3::Resampling -> ResamplingSpCVCoords

Active bindings

iters

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

Methods

Inherited methods


Method new()

Create an "coordinate-based" repeated resampling instance.

For a list of available arguments, please see sperrorest::partition_cv.

Usage

ResamplingSpCVCoords$new(id = "spcv_coords")

Arguments

id

character(1)
Identifier for the resampling strategy.


Method instantiate()

Materializes fixed training and test splits for a given task.

Usage

ResamplingSpCVCoords$instantiate(task)

Arguments

task

Task
A task to instantiate.


Method clone()

The objects of this class are cloneable with this method.

Usage

ResamplingSpCVCoords$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

library(mlr3)
task = tsk("ecuador")

# Instantiate Resampling
rcv = rsmp("spcv_coords", folds = 5)
rcv$instantiate(task)

# Individual sets:
rcv$train_set(1)
#>   [1]   7   8  12  13  14  15  17  21  24  25  32  35  44  46  54  63  65  66
#>  [19]  75  78  79  86  88  91  94  97 104 105 109 113 118 123 128 130 132 137
#>  [37] 140 142 143 145 147 161 162 163 166 171 181 182 188 191 192 195 196 200
#>  [55] 202 204 209 211 213 214 215 221 223 224 225 229 240 242 246 251 253 259
#>  [73] 261 262 266 270 277 279 280 282 285 287 288 305 306 308 313 318 320 322
#>  [91] 327 331 336 337 338 348 354 365 366 368 371 377 378 381 384 388 395 402
#> [109] 406 409 411 416 418 430 431 433 435 446 448 451 452 458 461 465 468 472
#> [127] 475 477 478 480 488 493 494 496 498 499 505 511 512 527 532 533 535 538
#> [145] 541 542 543 554 555 558 559 561 563 566 567 570 580 581 583 586 591 598
#> [163] 599 602 607 611 617 618 619 621 631 636 638 646 651 658 663 667 671 680
#> [181] 681 683 684 691 701 703 705 714 720 723 726 730 734 740 747 750  42  47
#> [199]  52  55  59  60  62  76  87  93  95  96  99 121 139 144 152 156 157 230
#> [217] 239 241 249 250 267 269 274 283 300 319 321 329 332 375 376 383 397 408
#> [235] 417 419 424 440 473 501 504 514 516 534 537 539 540 546 548 550 552 553
#> [253] 560 569 571 578 588 604 620 627 630 635 637 639 650 652 654 657 662 665
#> [271] 666 669 674 676 682 686 688 689 692 696 698 702 704 711 716 729 741 744
#> [289] 748 749 751   2   3   4   5  10  18  19  26  28  29  37  39  45  48  49
#> [307]  50  57  58  61  64  68  77  85  89  90 103 106 110 115 120 122 125 126
#> [325] 127 129 131 133 135 136 138 150 151 153 155 158 169 170 172 183 190 201
#> [343] 203 206 207 216 218 219 220 222 227 231 234 236 238 243 245 255 260 263
#> [361] 265 268 271 272 281 289 290 303 309 317 325 344 345 346 349 350 356 357
#> [379] 358 362 370 372 373 385 394 400 403 404 405 412 413 414 422 423 426 427
#> [397] 428 429 442 444 449 453 455 460 463 464 470 474 476 483 486 487 490 492
#> [415] 502 503 509 510 518 523 525 528 529 531 544 557 562 564 573 575 585 592
#> [433] 594 596 612 613 623 628 634 641 642 643 644 649 653 655 661 664 673 690
#> [451] 693 706 707 708 710 712 715 718 724 727 728 732 733 735 736 737 739 743
#> [469] 746   1   6  11  16  23  33  34  36  51  56  84 100 107 111 112 117 146
#> [487] 148 149 164 165 167 168 174 175 178 184 193 198 210 212 232 248 252 256
#> [505] 257 258 264 273 286 294 295 297 302 307 310 312 314 316 324 330 342 347
#> [523] 351 361 363 364 369 374 379 382 387 391 393 399 407 410 420 421 425 432
#> [541] 439 445 447 459 466 469 471 481 482 485 491 497 507 515 517 524 545 549
#> [559] 572 577 584 590 609 624 626 629 632 640 645 647 660 677 678 687 695 699
#> [577] 700 721 731 742 745
rcv$test_set(1)
#>   [1]   9  20  22  27  30  31  38  40  41  43  53  67  69  70  71  72  73  74
#>  [19]  80  81  82  83  92  98 101 102 108 114 116 119 124 134 141 154 159 160
#>  [37] 173 176 177 179 180 185 186 187 189 194 197 199 205 208 217 226 228 233
#>  [55] 235 237 244 247 254 275 276 278 284 291 292 293 296 298 299 301 304 311
#>  [73] 315 323 326 328 333 334 335 339 340 341 343 352 353 355 359 360 367 380
#>  [91] 386 389 390 392 396 398 401 415 434 436 437 438 441 443 450 454 456 457
#> [109] 462 467 479 484 489 495 500 506 508 513 519 520 521 522 526 530 536 547
#> [127] 551 556 565 568 574 576 579 582 587 589 593 595 597 600 601 603 605 606
#> [145] 608 610 614 615 616 622 625 633 648 656 659 668 670 672 675 679 685 694
#> [163] 697 709 713 717 719 722 725 738
# 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
#>      row_id fold
#>   1:      9    1
#>   2:     20    1
#>   3:     22    1
#>   4:     27    1
#>   5:     30    1
#>  ---            
#> 747:    700    5
#> 748:    721    5
#> 749:    731    5
#> 750:    742    5
#> 751:    745    5