Say n_repeats=5
and the number of fold is 3 (n_splits=3
).
Does that mean the validator is creating 3-folds for our estimator/model to use every fold (like what KFold is for), then repeating that process for 5 times?
That means our model will use a total of 5 x 3 = 15 folds?
Yes, you can basically achieve the same effect by calling KFolds.split()
n_repeats
times in a loop.
Example setup:
X = np.array([[1, 2], [3, 4], [1, 2], [3, 4]])
y = np.array([0, 0, 1, 1])
Then running:
rkf = RepeatedKFold(n_splits=2, n_repeats=1, random_state=2652124)
for train_index, test_index in rkf.split(X):
print("TRAIN:", train_index, "TEST:", test_index)
... produces:
TRAIN: [0 1] TEST: [2 3]
TRAIN: [2 3] TEST: [0 1]
... just like KFold(n_splits=2, random_state=2652124)
would. Changing to n_repeats=2
produces:
TRAIN: [0 1] TEST: [2 3]
TRAIN: [2 3] TEST: [0 1]
TRAIN: [1 2] TEST: [0 3]
TRAIN: [0 3] TEST: [1 2]
And so on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With