def split_train_val_groupKFold(sequence, numInputs, numOutputs, numJumps):
    ' Returns sets to train and cross-validate a model using group K-Fold technique\n    \n    Parameters:\n        sequence (array)  : Full training dataset\n        numInputs (int)   : Number of inputs X and Xcv used at each training\n        numOutputs (int)  : Number of outputs y and ycv used at each training\n        numJumps (int)    : Number of sequence samples to be ignored between (X,y) sets\n\n    Returns:\n        X (2D array)    : Array of numInputs arrays used for training\n        y (2D array)    : Array of numOutputs arrays used for training\n        Xcv (2D array)  : Array of numInputs arrays used for cross-validation\n        ycv (2D array)  : Array of numOutputs arrays used for cross-validation\n    \n    '
    (X, y, Xcv, ycv) = (dict(), dict(), dict(), dict())
    for j in np.arange(5):
        start_ix = 0
        end_ix = 0
        startCv_ix = 0
        endCv_ix = 0
        (X_it, y_it, Xcv_it, ycv_it) = (list(), list(), list(), list())
        i = 0
        n = 0
        while 1:
            if ((((i + 1) + j) % 5) != 0):
                start_ix = (endCv_ix + (numJumps * n))
                end_ix = (start_ix + numInputs)
                n += 1
                if ((end_ix + numOutputs) > (len(sequence) - 1)):
                    break
                seq_x = sequence[start_ix:end_ix]
                X_it.append(seq_x)
                seq_y = sequence[end_ix:(end_ix + numOutputs)]
                y_it.append(seq_y)
            else:
                startCv_ix = end_ix
                endCv_ix = (end_ix + numInputs)
                n = 0
                if ((endCv_ix + numOutputs) > len(sequence)):
                    break
                seq_xcv = sequence[startCv_ix:endCv_ix]
                Xcv_it.append(seq_xcv)
                seq_ycv = sequence[endCv_ix:(endCv_ix + numOutputs)]
                ycv_it.append(seq_ycv)
            i += 1
        X[j] = np.array(X_it)
        y[j] = np.array(y_it)
        Xcv[j] = np.array(Xcv_it)
        ycv[j] = np.array(ycv_it)
    if ((len(X) == 0) or (len(Xcv) == 0)):
        print('The sequence provided does not has size enough to populate the return arrays')
    return (X, y, Xcv, ycv)
Returns sets to train and cross-validate a model using group K-Fold technique

Parameters:
    sequence (array)  : Full training dataset
    numInputs (int)   : Number of inputs X and Xcv used at each training
    numOutputs (int)  : Number of outputs y and ycv used at each training
    numJumps (int)    : Number of sequence samples to be ignored between (X,y) sets

Returns:
    X (2D array)    : Array of numInputs arrays used for training
    y (2D array)    : Array of numOutputs arrays used for training
    Xcv (2D array)  : Array of numInputs arrays used for cross-validation
    ycv (2D array)  : Array of numOutputs arrays used for cross-validation
def split_train_val_groupKFold(sequence, numInputs, numOutputs, numJumps):
    ' Returns sets to train and cross-validate a model using group K-Fold technique\n    \n    Parameters:\n        sequence (array)  : Full training dataset\n        numInputs (int)   : Number of inputs X and Xcv used at each training\n        numOutputs (int)  : Number of outputs y and ycv used at each training\n        numJumps (int)    : Number of sequence samples to be ignored between (X,y) sets\n\n    Returns:\n        X (2D array)    : Array of numInputs arrays used for training\n        y (2D array)    : Array of numOutputs arrays used for training\n        Xcv (2D array)  : Array of numInputs arrays used for cross-validation\n        ycv (2D array)  : Array of numOutputs arrays used for cross-validation\n    \n    '
    (X, y, Xcv, ycv) = (dict(), dict(), dict(), dict())
    for j in np.arange(5):
        start_ix = 0
        end_ix = 0
        startCv_ix = 0
        endCv_ix = 0
        (X_it, y_it, Xcv_it, ycv_it) = (list(), list(), list(), list())
        i = 0
        n = 0
        while 1:
            if ((((i + 1) + j) % 5) != 0):
                start_ix = (endCv_ix + (numJumps * n))
                end_ix = (start_ix + numInputs)
                n += 1
                if ((end_ix + numOutputs) > (len(sequence) - 1)):
                    break
                seq_x = sequence[start_ix:end_ix]
                X_it.append(seq_x)
                seq_y = sequence[end_ix:(end_ix + numOutputs)]
                y_it.append(seq_y)
            else:
                startCv_ix = end_ix
                endCv_ix = (end_ix + numInputs)
                n = 0
                if ((endCv_ix + numOutputs) > len(sequence)):
                    break
                seq_xcv = sequence[startCv_ix:endCv_ix]
                Xcv_it.append(seq_xcv)
                seq_ycv = sequence[endCv_ix:(endCv_ix + numOutputs)]
                ycv_it.append(seq_ycv)
            i += 1
        X[j] = np.array(X_it)
        y[j] = np.array(y_it)
        Xcv[j] = np.array(Xcv_it)
        ycv[j] = np.array(ycv_it)
    if ((len(X) == 0) or (len(Xcv) == 0)):
        print('The sequence provided does not has size enough to populate the return arrays')
    return (X, y, Xcv, ycv)