public InstanceList [ ] nextSplit ( int numTrainFolds ) { InstanceList [ ] ret = new InstanceList [ 2 ] ; ret [ 0 ] = new InstanceList ( pipe ) ; ret [ 1 ] = new InstanceList ( pipe ) ; // train on folds [index, index+numTrainFolds), test on rest for ( int i = 0 ; i < folds . length ; i ++ ) { int foldno = ( index + i ) % folds . length ; InstanceList addTo ; if ( i < numTrainFolds ) { addTo = ret [ 0 ] ; } else { addTo = ret [ 1 ] ; } Iterator < Instance > iter = folds [ foldno ] . iterator ( ) ; while ( iter . hasNext ( ) ) addTo . add ( iter . next ( ) ) ; } index ++ ; return ret ; }
Returns the next split given the number of folds you want in the training data .