def compute_histogram(data, labels):
histogram = itemfreq(sorted(data))
for label in labels:
if label not in histogram[:,0]:
histogram = np.vstack((histogram,
np.array([[label, 0]], dtype=object)))
histogram = histogram[histogram[:,0].argsort()]
return histogram
# compute histograms
评论列表
文章目录