def crossvalidation(self, dataset, params, rep, shuffle=True):
        """ This method takes a dataset in form of a numpy array of shape n x d,
            where n is the number of data points and d is the dimensionality of 
            the data. It further requires the current params dictionary and the
            current repetition number. The flag 'shuffle' determines, if the
            dataset should be shuffled before returning the training and testing
            batches. There will be params['repetitions'] many equally sized batches, 
            the rest of the dataset is discarded.
        """
        if params['repetitions'] < 2:
            raise SystemExit('%i-fold cross validation does not make sense. Use at least 2 repetitions.'%params['repetitions'])
        
        key = int(hashlib.sha1(dataset).hexdigest()[:7], 16)
        indices = range(dataset.shape[0])
        if shuffle:
            # create permutation unique to dataset
            random.seed(key)
            indices = random.permutation(indices)
               
        batchsize = dataset.shape[0] // (params['repetitions'])
        if batchsize == 0:
            raise SystemExit('Too many repetitions for cross-validation with this dataset. Max. number of repetitions is %i.'%dataset.shape[0])
        
        batch = []
        for i in range(params['repetitions']):
            batch.append(dataset[indices[batchsize*i:batchsize*(i+1)]])

        # create training and test data
        trainset = zeros((0, batch[0].shape[1]), dtype=dataset.dtype)
        for i,b in enumerate(batch):
            if i == rep:
                testset = b
            else:
                trainset = r_[trainset, b]
        
        return trainset, testset
dataset/ETHPy150Open rueckstiess/expsuite/examples/crossvalidation/suite.py/MySuite.crossvalidation/original