import random
with open("datafile.txt", "rb") as f:
data = f.read().split('\n')
random.shuffle(data)
train_data = data[:50]
test_data = data[50:]
출처 : http://stackoverflow.com/questions/17412439/how-to-split-data-into-trainset-and-testset-randomly
'개발 > PYTHON' 카테고리의 다른 글
print newline 넘어가지 않게 ... (0) | 2017.02.15 |
---|---|
flatMap (0) | 2017.02.13 |
reload (0) | 2017.01.31 |
python list filtering 방법 (0) | 2017.01.25 |
PYTHON URL DOWNLOAD (0) | 2017.01.25 |
댓글