I was looking at MATLAB Help and want to work with "crossvalind" function. It would two parameters that you can use it.

If you use "HoldOut" you can define partition size of test and train data set and when you use "Kfold" you can define "fold counts".

Now I want to know is there a way to use "Kfold" parameter and define partition size of test and train data sets?

I checked it and it seems when you use "Kfold" as bellow code, it always default partition size like 75% to 25% .

indices = crossvalind('Kfold',species,10);


1 Answer 1


K-fold means that the validation step will be performed k times, each of them using a fraction $\frac{k-1}{k}$ for training and $\frac{1}{k}$ for validation. If you want a fixed validation fraction, choose the number of folds that fits:

  • 90%/10% : 10-fold
  • 75%/25% : 4-fold
  • etc.

I don't know about Matlab libraries or functions, but if you want to do custom folds, you'll probably have to sample train and validations sets "by hand".


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.