libs/data/utils.py
def simple_split_with_list(x, y, train_fraction=0.8, seed=None):
    """Splits data stored in a list.

    The data x and y are list of arrays with shape [batch, ...].
    These are split in two sets randomly using train_fraction over the number of
    element of the list. Then these sets are returned with
    the arrays concatenated along the first dimension
    """
    n_subjects = len(x)
    n_train = int(n_subjects * train_fraction)
    print('Split: Total %d -- Training %d' % (n_subjects, n_train))
    random_idx = np.random.RandomState(seed=seed).permutation(n_subjects)
    train_idx = random_idx[:n_train]
    test_idx = random_idx[n_train:]
    x_train = np.concatenate([x[i] for i in train_idx], axis=0)
    y_train = np.concatenate([y[i] for i in train_idx], axis=0)
    x_test = np.concatenate([x[i] for i in test_idx], axis=0)
    y_test = np.concatenate([y[i] for i in test_idx], axis=0)
    return x_train, y_train, x_test, y_test
Splits data stored in a list.

    The data x and y are list of arrays with shape [batch, ...].
    These are split in two sets randomly using train_fraction over the number of
    element of the list. Then these sets are returned with
    the arrays concatenated along the first dimension
    
Splits data stored in a list.
The data x and y are list of arrays with shape [batch, ...].
These are split in two sets randomly using train_fraction over the number of
element of the list. Then these sets are returned with
the arrays concatenated along the first dimension
Splits data stored in a list . The data x and y are list of arrays with shape [ batch ... ] . These are split in two sets randomly using train_fraction over the number of element of the list . Then these sets are returned with the arrays concatenated along the first dimension
def simple_split_with_list(x, y, train_fraction=0.8, seed=None):
    n_subjects = len(x)
    n_train = int(n_subjects * train_fraction)
    print('Split: Total %d -- Training %d' % (n_subjects, n_train))
    random_idx = np.random.RandomState(seed=seed).permutation(n_subjects)
    train_idx = random_idx[:n_train]
    test_idx = random_idx[n_train:]
    x_train = np.concatenate([x[i] for i in train_idx], axis=0)
    y_train = np.concatenate([y[i] for i in train_idx], axis=0)
    x_test = np.concatenate([x[i] for i in test_idx], axis=0)
    y_test = np.concatenate([y[i] for i in test_idx], axis=0)
    return x_train, y_train, x_test, y_test
def simple_split_with_list ( x , y , train_fraction = 0.8 , seed = None ) : n_subjects = len ( x ) n_train = int ( n_subjects * train_fraction ) print ( 'Split: Total %d -- Training %d' % ( n_subjects , n_train ) ) random_idx = np . random . RandomState ( seed = seed ) . permutation ( n_subjects ) train_idx = random_idx [ : n_train ] test_idx = random_idx [ n_train : ] x_train = np . concatenate ( [ x [ i ] for i in train_idx ] , axis = 0 ) y_train = np . concatenate ( [ y [ i ] for i in train_idx ] , axis = 0 ) x_test = np . concatenate ( [ x [ i ] for i in test_idx ] , axis = 0 ) y_test = np . concatenate ( [ y [ i ] for i in test_idx ] , axis = 0 ) return x_train , y_train , x_test , y_test
Splits data stored in a list.
Splits data stored in a list .
"""Splits data stored in a list.

    The data x and y are list of arrays with shape [batch, ...].
    These are split in two sets randomly using train_fraction over the number of
    element of the list. Then these sets are returned with
    the arrays concatenated along the first dimension
    """
x
y
train_fraction
seed