def kfold_cross_validation(ml, database, params, number_folds=10,
                           dataprocess=None):
    """
        Performs a k-fold cross-validation.

        Arguments:
            ml (:class:`ELMKernel` or :class:`ELMRandom`):
            database (numpy.ndarray): uses 'data' matrix to perform
                cross-validation.
            params (list): list of parameters from *ml* to train/test.
            number_folds (int): number of folds to be created from training and
                testing matrices.
            dataprocess (:class:`DataProcess`): an object that will pre-process
                database before training. Defaults to None.

        Returns:
            tuple: tuple of :class:`CVError` from training and testing.

    """

    if number_folds < 2:
        print("Error: Must have at least 2-folds.")
        return

    # Permute patterns
    np.random.shuffle(database)

    # Number of dimensions considering only 1 output
    n_dim = 1 - database.shape[1]
    number_patterns = database.shape[0]
    fold_size = np.ceil(number_patterns / number_folds)

    folds = []
    for k in range(number_folds):
        folds.append(database[k * fold_size: (k + 1) * fold_size, :])

    training_errors = []
    testing_errors = []

    for k in range(number_folds):

        # Training matrix is all folds except "k"
        training_matrix = \
            np.array(folds[:k] + folds[k+1:-1]).reshape(-1, n_dim + 1)
        if k < number_folds - 1:
            training_matrix = np.vstack((training_matrix, folds[-1]))

        testing_matrix = folds[k]

        # If dataprocess is available applies defined processes
        if dataprocess is not None:
            training_matrix, testing_matrix = \
                dataprocess.auto(training_matrix, testing_matrix)

        training_errors.append(ml.train(training_matrix, params))
        testing_errors.append(ml.test(testing_matrix))

    cv_training_error = CVError(training_errors)
    cv_testing_error = CVError(testing_errors)

    return cv_training_error, cv_testing_error
dataset/ETHPy150Open acba/elm/elm/mltools.py/kfold_cross_validation/swapped operands of `-`