python - 评估 K 意味着使用 python 进行聚类

标签 python scipy

我有一个数据集有点像这样:

enter image description here

我使用以下代码执行了K 均值聚类:

from scipy.cluster.vq import kmeans, vq
data=np.matrix(dataAll.ix[:,:-1])
centers, _ = kmeans(data, 3, iter=100)
cluster, _ = vq(data, centers)

在这里我想问一下如何评估k means clustering。我想获得精度、准确度、f measure 等值。

最佳答案

如果您有黄金标准/地面真实值,您可以使用我的代码 [ Link ] 计算成对精度、召回率、FScore 和 NMI。

注意,这篇文章是用印尼语写的,不过不用担心,你可以跳过所有的解释,直接看文章底部的代码。 [我写了 Matlab & Python 实现] python 代码是 this work 的分支 可用 here .

关于python - 评估 K 意味着使用 python 进行聚类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29760880/

相关文章:

python - Python 中使用嵌套循环的两位数乘法表

python - Python 中的 all() 函数何时打印 False?

python - Cython + OpenCV 和 NumPy

python - 尝试从 Pycharm 安装 sklearn 时出错 | arrayobject.h 不能是绝对的

python - python中集成多个函数错误

python - python 中的 Selenium webdriver : Re-using same web browser across testcases

python - 使用 Pandas 的赋值和 Lambda 函数向每行添加 Rand

python - 当 r=0 时,在 python 中以数值方式计算 1/r*d/dr(r*f)。 f 是 r 的函数

python - pd.rolling_mean 已弃用 - ndarrays 的替代品

python - scipy.stats 中支持 float128 (np.longdouble)