-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_test_random.py
61 lines (50 loc) · 3.75 KB
/
sample_test_random.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import random
def split_train_test(total_samples=0):
# Define the total number of samples
# total_samples = 2000
# Define the percentage split
train_percentage = 0.8
test_percentage = 0.2
# Calculate the number of samples for each split
num_train_samples = int(total_samples * train_percentage)
num_test_samples = total_samples - num_train_samples
# Generate a list of numbers from 1 to 1000
numbers = list(range(1, total_samples + 1))
# Randomly select numbers for the train set
random.seed(1)
train_set = random.sample(numbers, num_train_samples)
# Remove selected numbers from the list to ensure no overlap
for num in train_set:
numbers.remove(num)
# The remaining numbers constitute the test set
test_set = numbers
return train_set, test_set
# No preference
# train_set, test_set = split_train_test(total_samples=972)
# print(test_set)
# [5, 8, 14, 20, 24, 26, 35, 48, 50, 54, 57, 59, 60, 68, 69, 74, 78, 83, 96, 101, 108, 122, 126, 132, 144, 145, 148, 155, 156, 158, 169, 170, 177, 181, 198, 200,
# 207, 208, 209, 217, 220, 227, 234, 242, 243, 244, 245, 247, 255, 267, 268, 270, 272, 285, 290, 294, 295, 300, 301, 307, 310, 312, 317, 319, 332, 337, 338, 339,
# 344, 346, 351, 358, 360, 361, 367, 369, 371, 378, 379, 386, 397, 413, 416, 426, 429, 438, 439, 460, 463, 465, 475, 476, 477, 478, 482, 485, 487, 488, 494, 496,
# 499, 503, 504, 510, 511, 526, 533, 543, 547, 549, 559, 563, 566, 569, 582, 589, 591, 600, 611, 622, 625, 631, 633, 634, 641, 657, 662, 669, 674, 679, 682, 683,
# 684, 685, 688, 699, 700, 705, 709, 718, 724, 725, 726, 731, 732, 733, 735, 749, 750, 754, 758, 769, 774, 777, 782, 789, 791, 792, 793, 802, 807, 819, 820, 829,
# 834, 847, 849, 852, 853, 854, 860, 863, 865, 869, 870, 877, 885, 887, 888, 891, 894, 905, 908, 913, 914, 916, 917, 923, 947, 948, 949, 955, 965, 970, 971]
# color-color
# train_set, test_set = split_train_test(total_samples=612)
# print(test_set)
# [2, 12, 14, 18, 22, 35, 49, 55, 61, 62, 66, 68, 71, 73, 74, 80, 85, 90, 94, 96, 98, 99, 104, 107, 114, 119, 120, 122, 125, 126, 134, 135, 136, 141, 146, 155, 156, 158,
# 164, 166, 169, 172, 179, 181, 184, 188, 192, 197, 199, 218, 221, 226, 230, 242, 246, 257, 267, 268, 270, 272, 275, 287, 296, 305, 307, 310, 313, 317, 318, 330, 335, 342,
# 347, 351, 355, 363, 371, 372, 375, 379, 383, 392, 395, 396, 397, 399, 406, 411, 416, 421, 442, 456, 460, 463, 464, 468, 469, 475, 476, 478, 479, 491, 495, 497, 504, 506,
# 516, 531, 535, 542, 547, 557, 558, 564, 574, 579, 580, 586, 589, 591, 593, 605, 611]
# vertical-red
# train_set, test_set = split_train_test(total_samples=432)
# print(test_set)
# [4, 21, 24, 32, 39, 40, 46, 51, 59, 60, 64, 66, 68, 70, 72, 81, 85, 90, 94, 105, 109, 123, 124, 126, 129, 134, 139, 142, 143, 153, 154, 161, 164, 166, 168, 176, 179, 184,
# 186, 193, 194, 201, 211, 215, 220, 221, 224, 226, 227, 239, 244, 245, 252, 253, 262, 269, 274, 279, 280, 287, 293, 307, 309, 311, 316, 317, 322, 326, 327, 328, 331, 337,
# 343, 350, 354, 367, 368, 371, 373, 376, 379, 387, 403, 405, 407, 408, 409]
# horizontal-blue
train_set, test_set = split_train_test(total_samples=648)
print(test_set)
[1, 4, 12, 22, 35, 43, 49, 55, 61, 66, 68, 74, 80, 85, 90, 93, 95, 96, 98, 99, 101, 104, 114, 118, 119, 120, 122, 126, 128, 134, 135, 136, 143, 146, 154, 166,
169, 170, 172, 180, 188, 192, 196, 197, 213, 218, 221, 224, 227, 242, 244, 258, 263, 267, 270, 280, 285, 287, 296, 302, 306, 309, 312, 313, 320, 322, 328,
339, 342, 343, 344, 347, 350, 351, 358, 364, 371, 388, 392, 395, 398, 410, 411, 421, 422, 426, 431, 435, 439, 440, 443, 454, 455, 460, 466, 476, 478, 482,
489, 499, 522, 524, 528, 531, 538, 546, 550, 566, 569, 572, 573, 579, 580, 582, 591, 592, 595, 596, 597, 608, 610, 612, 617, 620, 625, 627, 633, 634, 637, 639]