在文档聚类过程中,作为数据预处理步骤,我首先应用奇异向量分解来获取
假设我的方法到目前为止是正确的(如果我漏掉了某些步骤,请纠正我),在这个阶段,使用输出执行交叉验证的标准方法是什么?任何关于如何将其应用于k-means的参考资料/实现/建议将不胜感激。
U
、S
和Vt
,然后通过选择适当数量的特征值来截断Vt
,从所阅读的此处得到良好的文档-文档相关性。现在我正在对矩阵Vt
的列执行聚类,以将相似的文档聚集在一起,并且为此选择了k-means算法,初始结果看起来对我来说是可接受的(使用k = 10个聚类),但我想更深入地研究如何选择k值本身。在确定k-means中聚类数k
之前,我被建议进行交叉验证。
在实施之前,我想弄清楚是否有一种内置的方法可以使用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)
假设我的方法到目前为止是正确的(如果我漏掉了某些步骤,请纠正我),在这个阶段,使用输出执行交叉验证的标准方法是什么?任何关于如何将其应用于k-means的参考资料/实现/建议将不胜感激。