import numpy as np
from collections import Counter
a = np.array([5,6,5,8,9,5,4,5,6,5,2])
print("各类样本数量:",(Counter(a)))
# 各类样本数量: Counter({5: 5, 6: 2, 8: 1, 9: 1, 4: 1, 2: 1})
02-19
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
import numpy as np
from collections import Counter
a = np.array([5,6,5,8,9,5,4,5,6,5,2])
print("各类样本数量:",(Counter(a)))
# 各类样本数量: Counter({5: 5, 6: 2, 8: 1, 9: 1, 4: 1, 2: 1})