If I want a random train/test split, I use the sklearn helper function:
In [1]: from sklearn.model_selection import train_test_split
...: train_test_split([1,2,3,4,5,6])
...:
Out[1]: [[1, 6, 4, 2], [5, 3]]
What is the most concise way to get a non-shuffled train/test split, i.e.
[[1,2,3,4], [5,6]]
EDIT Currently I am using
train, test = data[:int(len(data) * 0.75)], data[int(len(data) * 0.75):]
but hoping for something a little nicer. I have opened an issue on sklearn
https://github.com/scikit-learn/scikit-learn/issues/8844
EDIT 2: My PR has been merged, in scikit-learn version 0.19, you can pass the parameter shuffle=False
to train_test_split
to obtain a non-shuffled split.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…