1a = numpy.array([0, 3, 0, 1, 0, 1, 2, 1, 0, 0, 0, 0, 1, 3, 4])
2unique, counts = numpy.unique(a, return_counts=True)
3dict(zip(unique, counts))
4
5# {0: 7, 1: 4, 2: 1, 3: 2, 4: 1}
6
1import numpy as np
2y = np.array([0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1])
3num_zeros = (y == 0).sum()
4num_ones = (y == 1).sum()
5