使用Counter统计各类别的数目

https://blog.csdn.net/ziqingnian/article/details/111272798这篇博客中,对softmax的输出找到了对应概率最大的类别,可以使用Counter

对各类别的数目进行简单的统计

在使用Counter之前,需要使用ravel对array进行转换为一维的数组

import numpy as np
import pandas as pd
from collections import Counter

cluster = pd.read_csv('./cluster.csv', index_col=0)
cluster = np.array(cluster)
cluster = cluster.ravel()
print(Counter(cluster))

猜你喜欢

转载自blog.csdn.net/ziqingnian/article/details/111273564