Код: Выделить всё
def shuffle_and_split(data, test_ratio):
shuffled_indices=np.random.permutation(len(data))
test_set_size= int(len(data)*test_ratio)
test_indeces= shuffled_indices[:test_set_size]
train_indices= shuffled_indices[test_set_size]
return data.iloc[train_indices], data.iloc[test_indices]
Подробнее здесь: https://stackoverflow.com/questions/798 ... it-program