protected List<List<T>> splitData(Iterable<T> data,int dataSize){
  List<List<T>> splits=new ArrayList<>();
  int size=(int)Math.ceil((double)dataSize / numFolds);
  int current=0;
  List<T> l=new ArrayList<>();
  int count=0;
  for (  T item : data) {
    l.add(item);
    count++;
    if (count > dataSize)     break;
  }
  Collections.shuffle(l,randomSeed);
  for (int i=0; i < numFolds; i++) {
    int start=current;
    int end=Math.min(current + size,dataSize);
    splits.add(l.subList(start,end));
    current=end;
  }
  return splits;
}

protected List < List < T > > splitData ( Iterable < T > data , int dataSize ) { List < List < T > > splits = new ArrayList < > ( ) ; int size = ( int ) Math . ceil ( ( double ) dataSize / numFolds ) ; int current = 0 ; List < T > l = new ArrayList < > ( ) ; int count = 0 ; for ( T item : data ) { l . add ( item ) ; count ++ ; if ( count > dataSize ) break ; } Collections . shuffle ( l , randomSeed ) ; for ( int i = 0 ; i < numFolds ; i ++ ) { int start = current ; int end = Math . min ( current + size , dataSize ) ; splits . add ( l . subList ( start , end ) ) ; current = end ; } return splits ; }
splits the data into numfolds parts . < p > note : this splits the data into k folds uniformly . if the classes are not equally distributed , then this is wrong . instead , override this to do a stratified split , so that the split proportions are maintained .
