Created
March 20, 2017 17:13
-
-
Save orsenthil/0903abb14843a4550095ada0536d6db6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
total = 1052 | |
k = 10 | |
indices = np.arange(total) | |
np.random.shuffle(indices) | |
indices = indices.tolist() | |
start = 0 | |
end = total | |
step = int(total / k) + 1 | |
total_k = [] | |
for slice in range(start, end, step): | |
testing = indices[slice: slice + step] | |
training = indices[:slice] + indices[slice + step:] | |
print "testing (%d-%d) %d training (%d-%d, %d-%d) %d" % (slice, slice + step -1, len(testing), 0, | |
slice-1, slice + step, total -1, len(training)) | |
assert (len(testing) + len(training)) == total | |
total_k.append((testing, training)) | |
assert len(total_k) == k | |
arr = np.arange(10) | |
np.random.shuffle(arr) | |
print arr | |
copy_indices = [3, 7, 8] | |
print arr[copy_indices] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment