您好我正在尝试使用简单的虹膜数据集运行mahout kmeans聚类。我使用以下代码将csv转换为mahout输入
https://github.com/josephmisiti/hadoop-examples/blob/master/mahout/clustering/CSVToMahout.java
代码在将输出提供给kmeans时成功运行。 mahout接受代码并执行提供输出。
现在的问题是让它回到人类可读的格式。
Configuration config = new Configuration();
Path path = new Path(args[0]);
SequenceFile.Reader reader = new SequenceFile.Reader(FileSystem.get(config), path, config);
DenseVector dv = new DenseVector();
WritableComparable key = (WritableComparable) reader.getKeyClass().newInstance();
Writable value = (Writable) reader.getValueClass().newInstance();
long position = reader.getPosition();
DataOutput out = null;
//Cluster cl= new Cluster();
while(reader.next(key,value))
{
System.out.println("Key is: "+key +" value is: "+value+"\n");
//System.out.println(out.toString());
}
输出是这样的
键是:0值是:org.apache.mahout.clustering.iterator.ClusterWritable@47b8b32b
键是:1值是:org.apache.mahout.clustering.iterator.ClusterWritable@47b8b32b
键是:2值是:org.apache.mahout.clustering.iterator.ClusterWritable@47b8b32b
提前致谢