def split_sets(data, training_percent=None, n_test_samples=None, perm=False):
    """
        Split data matrix into training and test matrices.

        Training matrix size will be set using the training_percent
        parameter, so its samples are the firsts samples found at
        data matrix, the rest of samples will be testing matrix.

        If neither training_percent or number_test_samples are set, an error
        will happen, only one of the parameters can be set at a time.

        Arguments:
            data (numpy.ndarray): A matrix containing nxf patterns features.
            training_percent (float): An optional parameter used to
                calculate the number of patterns of training matrix.
            n_test_samples (int): An optional parameter used to set the
                number of patterns of testing matrix.
            perm (bool): A flag to choose if should permute(shuffle) database
                before splitting sets.

        Returns:
            tuple: Both training and test matrices.

    """

    number_of_samples = data.shape[0]

    # Permute data
    if perm:
        np.random.shuffle(data)

    if n_test_samples is not None:
        training_samples = number_of_samples - n_test_samples
    elif training_percent is not None:
        training_samples = round(number_of_samples * training_percent)
    else:
        raise Exception("Error: Missing \"training_percent\" or \"numberTestSamples\""
                        "parameter.")

    training_matrix = data[0:training_samples, :]
    testing_matrix = data[training_samples:, :]

    return training_matrix, testing_matrix
dataset/ETHPy150Open acba/elm/elm/mltools.py/split_sets/original