-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclass_dist.py
36 lines (24 loc) · 2.39 KB
/
class_dist.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
import matplotlib.pyplot as plt
train_class_counts = {0: 0, 1: 262465, 2: 7113, 3: 43867, 4: 8725, 5: 5135, 6: 6069, 7: 4571, 8: 9973, 9: 10759, 10: 12884, 11: 1865, 12: 0, 13: 1983, 14: 1285, 15: 9838, 16: 10806, 17: 4768, 18: 5508, 19: 6587, 20: 9509, 21: 8147, 22: 5513, 23: 1294, 24: 5303, 25: 5131, 26: 0, 27: 8720, 28: 11431, 29: 0, 30: 0, 31: 12354, 32: 6496, 33: 6192, 34: 2682, 35: 6646, 36: 2685, 37: 6347, 38: 9076, 39: 3276, 40: 3747, 41: 5543, 42: 6126, 43: 4812, 44: 24342, 45: 0, 46: 7913, 47: 20650, 48: 5479, 49: 7770, 50: 6165, 51: 14358, 52: 9458, 53: 5851, 54: 4373, 55: 6399, 56: 7308, 57: 7852, 58: 2918, 59: 5821, 60: 7179, 61: 6353, 62: 38491, 63: 5779, 64: 8652, 65: 4192, 66: 0, 67: 15714, 68: 0, 69: 0, 70: 4157, 71: 0, 72: 5805, 73: 4970, 74: 2262, 75: 5703, 76: 2855, 77: 6434, 78: 1673, 79: 3334, 80: 225, 81: 5610, 82: 2637, 83: 0, 84: 24715, 85: 6334, 86: 6613, 87: 1481, 88: 4793, 89: 198, 90: 1954}
val_class_counts = {0: 0, 1: 11004, 2: 316, 3: 1932, 4: 371, 5: 143, 6: 285, 7: 190, 8: 415, 9: 430, 10: 637, 11: 101, 12: 0, 13: 75, 14: 60, 15: 413, 16: 440, 17: 202, 18: 218, 19: 273, 20: 361, 21: 380, 22: 255, 23: 71, 24: 268, 25: 232, 26: 0, 27: 371, 28: 413, 29: 0, 30: 0, 31: 540, 32: 254, 33: 303, 34: 115, 35: 241, 36: 69, 37: 263, 38: 336, 39: 146, 40: 148, 41: 179, 42: 269, 43: 225, 44: 1025, 45: 0, 46: 343, 47: 899, 48: 215, 49: 326, 50: 253, 51: 626, 52: 379, 53: 239, 54: 177, 55: 287, 56: 316, 57: 371, 58: 127, 59: 285, 60: 338, 61: 316, 62: 1791, 63: 261, 64: 343, 65: 163, 66: 0, 67: 697, 68: 0, 69: 0, 70: 179, 71: 0, 72: 288, 73: 231, 74: 106, 75: 283, 76: 153, 77: 262, 78: 55, 79: 143, 80: 9, 81: 225, 82: 126, 83: 0, 84: 1161, 85: 267, 86: 277, 87: 36, 88: 191, 89: 11, 90: 57}
train_vals = sorted(list(train_class_counts.values()))
train_vals.reverse()
sum_train = sum(train_vals)
val_vals = sorted(list(val_class_counts.values()))
val_vals.reverse()
sum_val = sum(val_vals)
for k in range(len(train_vals)):
train_vals[k] /= sum_train
for k in range(len(val_vals)):
val_vals[k] /= sum_val
for i in range(len(train_vals) - len(val_vals)):
val_vals.append(0)
print(train_vals[0] / sum(train_vals))
print(val_vals[0] / sum(val_vals))
plt.plot(train_vals, label = "train set")
plt.plot(val_vals, label = "val set")
plt.xlabel("Classes")
plt.ylabel("Proportion of total objects")
# plt.title("Class distribution train & val in decreasing order")
plt.legend()
plt.show()