def get_cross_validation_datasets(dataset, n_fold, order=None):
 if (order is None):
  order = numpy.arange(len(dataset))
 else:
  order = numpy.array(order)
 whole_size = len(dataset)
 borders = [((whole_size * i) // n_fold) for i in six.moves.range((n_fold + 1))]
 test_sizes = [(borders[(i + 1)] - borders[i]) for i in six.moves.range(n_fold)]
 splits = []
 for test_size in reversed(test_sizes):
  size = (whole_size - test_size)
  splits.append(split_dataset(dataset, size, order))
  new_order = numpy.empty_like(order)
  new_order[:test_size] = order[(- test_size):]
  new_order[test_size:] = order[:(- test_size)]
  order = new_order
 return splits

def get_cross_validation_datasets ( dataset , n_fold , order = None ) : if ( order is None ) : order = numpy . arange ( len ( dataset ) ) else : order = numpy . array ( order ) whole_size = len ( dataset ) borders = [ ( ( whole_size * i ) // n_fold ) for i in six . moves . range ( ( n_fold + 1 ) ) ] test_sizes = [ ( borders [ ( i + 1 ) ] - borders [ i ] ) for i in six . moves . range ( n_fold ) ] splits = [ ] for test_size in reversed ( test_sizes ) : size = ( whole_size - test_size ) splits . append ( split_dataset ( dataset , size , order ) ) new_order = numpy . empty_like ( order ) new_order [ : test_size ] = order [ ( - test_size ) : ] new_order [ test_size : ] = order [ : ( - test_size ) ] order = new_order return splits
creates a set of training/test splits for cross validation .