Hi, I have an array of 100 elements. I want to split the array to 70 (test set) and 30 (train set) randomly.
N=100
A = rand(N);
n = convert(Int, ceil(N*0.7))
testindex = sample(1:size(A,1), replace=false,n)
testA = A[testindex];
How can I get the train set?
I could loop through testA and A to get trainA as below
trainA = Array(eltype(testA), N-n);
k=1
for elem in A
if !(elem in testA)
trainA[k] = elem
k=k+1
end
end
Is there a more efficient or elegant way to do this?
Thanks!
