I'm trying to randomly split a list X
with len(X) = 150
into two lists X_train
and X_test
with len(X_train) = 105
and len(X_test) = 45
.
split = np.random.choice(150, 105)
X_train = [X[i] for i in split]
X_test = [X[i] for i not in split]
But in line 3 I get a SyntaxError.
How would I do this correctly?