【问题标题】:Mahout clustered pointsMahout 聚集点
【发布时间】:2014-10-22 02:02:27
【问题描述】:

当我在 Mahoot 中运行 kmeans 集群时,我得到了两个文件夹,clusters-x 和 clusteredPoints。

我已使用集群转储器读取集群中心,但不知何故无法访问 clusteredPoints?具体来说,我需要从代码中完成。

奇怪的是,我在 clusteredPoints 中的文件大小始终是 128 字节,当我尝试循环遍历结果,使用下一个代码时,它只是跳出循环,就像没有结果一样,但我得到了集群中心,这导致假设点是聚集的。

    IntWritable key = new IntWritable();
    WeightedPropertyVectorWritable value = new WeightedPropertyVectorWritable();
    while (reader.next(key, value)) {
        System.out.println(
        value.toString() + " belongs to cluster " + key.toString());
    }

它只是跳出循环吗?

真的很奇怪,任何帮助都会很棒,谢谢。

【问题讨论】:

    标签: cluster-analysis mahout


    【解决方案1】:

    您需要打开您的最终集群文件('clusteredPoints/part-m-0'):

    Configuration conf = new Configuration();
    FileSystem fs = FileSystem.get(conf);
    SequenceFile.Reader reader = new SequenceFile.Reader(fs, new Path("output/clusteredPoints/part-m-0"), conf);
    

    然后,假设你的键是 int 的,遍历它(就像你已经做过的那样),用:

    IntWritable key = new IntWritable();
        WeightedPropertyVectorWritable value = new WeightedPropertyVectorWritable();
        while (reader.next(key, value)) {
            LOG.info("{} belongs to cluster {}", value.toString(), key.toString());
        }
        reader.close();
    

    如果您仍然无法执行此操作,我可以发布一个完整的示例。

    【讨论】:

      猜你喜欢
      • 2014-11-01
      • 2013-01-10
      • 2014-10-15
      • 2016-09-06
      • 2010-12-23
      • 1970-01-01
      • 2012-07-10
      • 2013-02-22
      • 2015-02-05
      相关资源
      最近更新 更多