Mahout-Kmeans MR

来源:互联网 发布:淘宝好店 知乎 编辑:程序博客网 时间:2024/06/04 23:12

Mapper (ClusterClassificationMapper.java)

 protected void setup(Context context) throws IOException, InterruptedException {    super.setup(context);        Configuration conf = context.getConfiguration();    String clustersIn = conf.get(ClusterClassificationConfigKeys.CLUSTERS_IN);    threshold = conf.getFloat(ClusterClassificationConfigKeys.OUTLIER_REMOVAL_THRESHOLD, 0.0f);    emitMostLikely = conf.getBoolean(ClusterClassificationConfigKeys.EMIT_MOST_LIKELY, false);        clusterModels = Lists.newArrayList();        if (clustersIn != null && !clustersIn.isEmpty()) {      Path clustersInPath = new Path(clustersIn);      clusterModels = populateClusterModels(clustersInPath, conf);      ClusteringPolicy policy = ClusterClassifier          .readPolicy(finalClustersPath(clustersInPath));      clusterClassifier = new ClusterClassifier(clusterModels, policy);    }    clusterId = new IntWritable();  }

A. clusterModels 
   保存了center的vectorB. clusterModels = populateClusterModels(clustersInPath, conf);


原创粉丝点击