本文主要是介绍K-Means实现HelloWorld聚类代码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
<strong><span style="font-size:18px;">/**** @author YangXin* @info 代码以in-memory模式使用mahout的k-means,* 对平面上点的结合进行聚类*/package com;import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.SequenceFile;
import org.apache.hadoop.io.Text;
import org.apache.mahout.clustering.WeightedVectorWritable;
import org.apache.mahout.clustering.kmeans.Cluster;
import org.apache.mahout.clustering.kmeans.KMeansDriver;
import org.apache.mahout.common.distance.EuclideanDistanceMeasure;
import org.apache.mahout.math.RandomAccessSparseVector;
import org.apache.mahout.math.Vector;
import org.apache.mahout.math.VectorWritable;public class SimpleKMeansClustering {p
这篇关于K-Means实现HelloWorld聚类代码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!