You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Miteshkumar Patel <mi...@yahoo-inc.com.INVALID> on 2015/06/24 22:42:00 UTC

provide name to id mapping in spectralkmeansDriver.java example

Hi All,
I'm new to Mahout. I'm using the SpectralKMeansDriver.java example provided in the Mahout library. The code works fine. 
After code execution I want to find which IDs belong to which clusters. 
I'm using the 'mahout clusterdump' command to dump the clusters and it dumps the centroid, radius and points. but I can't find which ID belongs to which cluster information.
I found the below snipnet in the code example 'SpectralKMeansDriver.java',  which I presume is looking for the input mapping file but how do can I provide this from the command line.    // Restore name to id mapping and read through the cluster assignments    Path mappingPath = new Path(new Path(conf.get("hadoop.tmp.dir")), "generic_input_mapping");    List<String> mapping = new ArrayList<>();    FileSystem fs = FileSystem.get(mappingPath.toUri(), conf);    if (fs.exists(mappingPath)) {      SequenceFile.Reader reader = new SequenceFile.Reader(fs, mappingPath, conf);      Text mappingValue = new Text();      IntWritable mappingIndex = new IntWritable();      while (reader.next(mappingIndex, mappingValue)) {        String s = mappingValue.toString();        mapping.add(s);      }      HadoopUtil.delete(conf, mappingPath);    } else {      log.warn("generic input mapping file not found!");    }
Would appreciate any pointers.
Regards,Mitesh