Internal function for constructing a class-balanced segment list for cross-validation (copy from a previous verson from package pamr).
balanced.folds(y, nfolds = min(min(table(y)), 10))
y | A categorical vector of class memberships |
---|---|
nfolds | The required number of CV-segements or "folds". |
A list of sample segments.
data(BCdata) balanced.folds(BCdata$Y)#> [[1]] #> [1] 83 124 16 73 109 39 69 116 35 1 127 95 #> #> [[2]] #> [1] 12 94 60 9 22 56 21 4 41 84 18 93 103 86 #> #> [[3]] #> [1] 34 115 108 74 32 67 91 66 90 129 53 31 126 #> #> [[4]] #> [1] 2 5 119 113 46 81 45 112 47 48 72 75 #> #> [[5]] #> [1] 57 40 80 130 68 63 52 106 55 78 62 17 107 #> #> [[6]] #> [1] 105 3 54 29 100 120 118 27 19 50 96 125 8 #> #> [[7]] #> [1] 58 87 104 14 70 13 44 79 114 6 30 89 82 #> #> [[8]] #> [1] 76 37 23 99 43 121 33 128 101 36 97 71 111 #> #> [[9]] #> [1] 85 42 61 123 102 77 7 117 59 64 25 65 98 10 #> #> [[10]] #> [1] 20 122 49 88 28 92 26 38 11 51 24 15 110 #>