【问题标题】:Cannot get clustering output Mahout无法获得聚类输出 Mahout
【发布时间】:2014-10-18 13:30:25
【问题描述】:

我在 Mahout 中运行 kmeans,作为输出,我得到文件夹 clusters-x、clusters-x-final 和 clusteredPoints。

如果我理解得很好,clusters-x 是每次迭代中的质心位置,clusters-x-final 是最终质心位置,clusteredPoints 应该是用集群 id 和权重聚类的点,它代表属于集群的概率(取决于点与其质心之间的距离)。另一方面,clusters-x 和 clusters-x-final 包含簇的质心、元素个数、质心的特征值和集群的半径(质心与最远点之间的距离。

如何检查这些输出?

我从终端成功地为 clusters-x 和 clusters-x-final 使用了 cluster dumper,但是当我使用 clusteredPoints 时,我得到了一个空文件?似乎是什么问题?

如何从代码中获取这些值?我的意思是,属于簇的质心值和点?

对于 clusteredPoint,我在 while 循环中使用 IntWritable 作为键,使用 WeightedPropertyVectorWritable 作为值,但它通过循环就像 clusteredPoints 中没有元素一样?

这更奇怪,因为我用 clusterDumper 得到的文件是空的?

可能是什么问题?

任何帮助将不胜感激!

【问题讨论】:

    标签: cluster-analysis mahout k-means


    【解决方案1】:

    我相信您对数据的解释是正确的(我只与 Mahout 合作了大约 3 周,因此可能需要更有经验的人来权衡一下)。

    至于将点链接回创建它们的输入,我使用了 NamedVector,其中名称是向量的键。当您读取其中一个生成的点文件(clusteredPoints)时,您可以将每一行(点向量)转换回 NamedVector 并使用 .getName() 检索名称。

    根据评论更新

    当您最初将数据读入 Mahout 时,您会将其转换为向量集合,然后将其写入文件(点)以供稍后在聚类算法中使用。 Mahout 为您提供了几种可供您使用的 Vector 类型,但它们还允许您访问名为 NamedVector 的 Vector 包装器类,该类可让您识别每个向量。

    例如,您可以按如下方式创建每个 NamedVector:

    NamedVector nVec = new NamedVector(
        new SequentialAccessSparseVector(vectorDimensions), 
        vectorName
        );
    

    然后你将你的 NamedVectors 集合写入文件,如下所示:

    SequenceFile.Writer writer = new SequenceFile.Writer(...);
    VectorWritable writable = new VectorWritable();
    
    // the next two lines will be in a loop, but I'm omitting it for clarity
    writable.set(nVec);
    writer.append(new Text(nVec.getName()), nVec);
    

    您现在可以将此文件用作其中一种聚类算法的输入。

    使用您的点文件运行其中一种聚类算法后,它将生成另一个点文件,但它将位于名为 clusteredPoints 的目录中。

    然后您可以读取此点文件并提取与每个向量关联的名称。它看起来像这样:

    IntWritable clusterId = new IntWritable();
    WeightedPropertyVectorWritable vector = new WeightedPropertyVectorWritable();
    
    while (reader.next(clusterId, vector))
    {
        NamedVector nVec = (NamedVector)vector.getVector();
        // you now have access to the original name using nVec.getName()
    }
    

    【讨论】:

      【解决方案2】:

      检查名为“clusterClassificationThreshold”的参数。

      clusterClassificationThreshold 应该是 0。

      你可以查看这个http://mail-archives.apache.org/mod_mbox/mahout-user/201211.mbox/%3C50B62629.5020700@windwardsolutions.com%3E

      【讨论】:

        猜你喜欢
        • 2012-08-04
        • 1970-01-01
        • 2017-06-04
        • 2021-11-23
        • 2013-01-10
        • 2014-10-15
        • 2016-09-06
        • 1970-01-01
        • 2014-08-07
        相关资源
        最近更新 更多