首页 > 代码库 > 计算簇间距离
计算簇间距离
<strong><span style="font-size:18px;">/*** * @author YangXin * @info 计算簇间距 */ package unitTen; 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.SequenceFile; import org.apache.hadoop.io.Writable; import org.apache.mahout.clustering.Cluster; import org.apache.mahout.common.distance.CosineDistanceMeasure; import org.apache.mahout.common.distance.DistanceMeasure; public class InterClusterDistances { public static void main(String args[]) throws Exception { String inputFile = "reuters-kmeans-clusters/clusters-6/part-r-00000"; Configuration conf = new Configuration(); Path path = new Path(inputFile); System.out.println("Input Path: " + path); FileSystem fs = FileSystem.get(path.toUri(), conf); List<Cluster> clusters = new ArrayList<Cluster>(); SequenceFile.Reader reader = new SequenceFile.Reader( fs, path, conf); Writable key = (Writable) reader.getKeyClass() .newInstance(); Writable value = http://www.mamicode.com/(Writable) reader.getValueClass()"Maximum Intercluster Distance: " + max); System.out.println("Minimum Intercluster Distance: " + min); System.out .println("Average Intercluster Distance(Scaled): " + (sum / count - min) / (max - min)); } } </span></strong>
计算簇间距离
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。