c = cvpartition(n,'KFold',k)
The above syntax of the function randomly splits the “n” observations into “k” disjoint sets of roughly equal size. Hence, it doesn’t ensure if all the “k” sets include samples corresponding to all the classes. If your dataset is highly imbalanced, there is a possibility that some of the sets might not contain samples corresponding to the minority class.
c = cvpartition(group,'KFold',k,'Stratify',true)
While, the above syntax of the function ensures that each of the “k” sets contain approximately the same percentage of samples for each class as the complete set.
In case of large imbalance in the distribution of target classes, it is recommended to use stratified sampling to ensure that relative class frequencies are approximately preserved in each train and validation fold.
For more syntaxes of this function, refer to this link.
Best Answer