Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

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?

1 Answer

0 votes
by (41.4k points)

You can see the same effect by calling KFolds.split() n_repeats times in a loop.

Example:

X = np.array([[1, 2], [3, 4], [1, 2], [3, 4]])

y = np.array([0, 0, 1, 1])

Then after 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)

Output:

TRAIN: [0 1] TEST: [2 3]

TRAIN: [2 3] TEST: [0 1]

Similar to what  KFold(n_splits=2, random_state=2652124) would do.

 Now, changing to n_repeats=2 will give output as:

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 wish to learn more about how to use python for data science, then go through this data science python course by Intellipaat for more insights.

Browse Categories

...