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.

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

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 -> ResamplingRepeatedSpCVCoords

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

ResamplingRepeatedSpCVCoords$new(id = "repeated_spcv_coords")

Arguments

id

character(1)
Identifier for the resampling strategy.


Method folds()

Translates iteration numbers to fold number.

Usage

ResamplingRepeatedSpCVCoords$folds(iters)

Arguments

iters

integer()
Iteration number.


Method repeats()

Translates iteration numbers to repetition number.

Usage

ResamplingRepeatedSpCVCoords$repeats(iters)

Arguments

iters

integer()
Iteration number.


Method instantiate()

Materializes fixed training and test splits for a given task.

Usage

ResamplingRepeatedSpCVCoords$instantiate(task)

Arguments

task

Task
A task to instantiate.


Method clone()

The objects of this class are cloneable with this method.

Usage

ResamplingRepeatedSpCVCoords$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Examples

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

# Instantiate Resampling
rrcv = rsmp("repeated_spcv_coords", folds = 3, repeats = 5)
rrcv$instantiate(task)

# Individual sets:
rrcv$iters
#> [1] 15
rrcv$folds(1:6)
#> [1] 1 2 3 1 2 3
rrcv$repeats(1:6)
#> [1] 1 1 1 2 2 2

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

# Internal storage:
rrcv$instance # table
#>       row_id rep fold
#>    1:      1   1    2
#>    2:      2   1    2
#>    3:      3   1    2
#>    4:      4   1    2
#>    5:      5   1    2
#>   ---                
#> 4606:    918   5    3
#> 4607:    919   5    3
#> 4608:    920   5    3
#> 4609:    921   5    1
#> 4610:    922   5    1