k-fold交叉验证用于确定k均值k?

Leg*_*end 5 python statistics nlp numpy machine-learning

在文档聚类处理,作为数据预处理步骤中,我首先施加奇异向量分解,以获得U,S并且Vt然后通过选择本征值I截断的合适数量Vt,这现在给我一个很好的文档的文档相关性从我看这里.现在我在矩阵的列上执行聚类以将Vt类似的文档聚集在一起为此我选择k-means并且初始结果看起来对我来说是可接受的(k = 10个簇)但我想更深入地选择k值本身.为了确定kk-means中的聚类数量,我建议考虑交叉验证.

在实现它之前,我想弄清楚是否有使用numpy或scipy实现它的内置方法.目前,我的表现方式kmeans是简单地使用scipy中的函数.

import numpy, scipy

# Preprocess the data and compute svd
U, S, Vt = svd(A) # A is the TFIDF representation of the original term-document matrix

# Obtain the document-document correlations from Vt
# This 50 is the threshold obtained after examining a scree plot of S
docvectors = numpy.transpose(self.Vt[0:50, 0:]) 

# Prepare the data to run k-means
whitened = whiten(docvectors)
res, idx = kmeans2(whitened, 10, iter=20)
Run Code Online (Sandbox Code Playgroud)

假设到目前为止我的方法是正确的(如果我错过了一些步骤,请纠正我),在这个阶段,使用输出执行交叉验证的标准方法是什么?关于如何将其应用于k-means的任何参考/实现/建议将不胜感激.

Fre*_*Foo 7

要运行k折交叉验证,您需要一些质量测量来优化.这可以是诸如精度或F 1的分类测量,或者诸如V测量的专用测量.

即使我所知的聚类质量测量也需要标记数据集("基础事实")才能工作; 与分类的区别在于,您只需要为评估标记部分数据,而k-means算法可以使用所有数据来确定质心,从而确定聚类.

V-measure和其他几个分数在scikit-learn中实现,以及通用交叉验证代码和"网格搜索"模块,该模块根据使用k-fold CV的指定评估度量进行优化.免责声明:我参与了scikit-learn开发,虽然我没有写任何提到的代码.