lst_y = [ y for i, y in enumerate(labels) if i%nfold != test_id ]
test_x = [ x for i, x in enumerate(data) if i%nfold == test_id ]
test_y = [ y for i, y in enumerate(labels) if i%nfold == test_id ]
perm = range(len(lst_x))
random.shuffle(perm)
M = int(len(lst_x)*0.9)
train_x = [ lst_x[i] for i in perm[:M] ]
train_y = [ lst_y[i] for i in perm[:M] ]
valid_x = [ lst_x[i] for i in perm[M:] ]
valid_y = [ lst_y[i] for i in perm[M:] ]
return train_x, train_y, valid_x, valid_y, test_x, test_y
def cv_split2(data, labels, nfold, valid_id):
After Change
lst_y = [ y for i, y in enumerate(labels) if i%nfold != test_id ]
test_x = [ x for i, x in enumerate(data) if i%nfold == test_id ]
test_y = [ y for i, y in enumerate(labels) if i%nfold == test_id ]
perm = list(range(len(lst_x)))
random.shuffle(perm)
M = int(len(lst_x)*0.9)
train_x = [ lst_x[i] for i in perm[:M] ]
train_y = [ lst_y[i] for i in perm[:M] ]
valid_x = [ lst_x[i] for i in perm[M:] ]
valid_y = [ lst_y[i] for i in perm[M:] ]
return train_x, train_y, valid_x, valid_y, test_x, test_y
def cv_split2(data, labels, nfold, valid_id):