I guess I understand the basic idea of cross-validated, partitioning a training set into k folds, fitting a model and computing the score k consecutive times.

enter image description here

I am trying to figure out the details. Take iris dataset as our example

  1. partition 150 instances into training set of 90 and test set of 60.
  2. partition 90 instances into 5 folds,

What is the detailed procedure of the following code?

>>> scores = cross_val_score(clf, X, y, cv=5)
>>> scores
array([0.96..., 1.  ..., 0.96..., 0.96..., 1.        ])

Does the detailed procedure run this way?

split 1: perform training on fold2 to fold5, perform validating on the remaining part, fold1 in this case.

split 2: perform training on fold1, fold3 to fold5, perform validating on the remaining part, fold2 in this case.

Are the fold1s in split 1 and split 2 the same fold? In other words, is it necessary to randomize the training set before split 2?


1 Answer 1


Yes you got the procedure correct. They are the same fold, it does not randomize the set again.

There is a variant of cross validation, where after you finish one round like the above, you randomize and split the data into a different 5 fold, this is called repeated cross validation


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.