当前位置: 首页>>代码示例>>Java>>正文


Java ClusterWritable.setValue方法代码示例

本文整理汇总了Java中org.apache.mahout.clustering.iterator.ClusterWritable.setValue方法的典型用法代码示例。如果您正苦于以下问题:Java ClusterWritable.setValue方法的具体用法?Java ClusterWritable.setValue怎么用?Java ClusterWritable.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.mahout.clustering.iterator.ClusterWritable的用法示例。


在下文中一共展示了ClusterWritable.setValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reduce

import org.apache.mahout.clustering.iterator.ClusterWritable; //导入方法依赖的package包/类
@Override
protected void reduce(Text arg0, Iterable<VectorWritable> values,
    Context context) throws IOException, InterruptedException {
  for (VectorWritable value : values) {
    Vector point = value.get();
    canopyClusterer.addPointToCanopies(point, canopies);
  }
  for (Canopy canopy : canopies) {
    ClusterWritable clusterWritable = new ClusterWritable();
    canopy.computeParameters();
    if (canopy.getNumObservations() > clusterFilter) {
  	clusterWritable.setValue(canopy);
      context.write(new Text(canopy.getIdentifier()), clusterWritable);
    }
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:17,代码来源:CanopyReducer.java

示例2: writeToSeqFiles

import org.apache.mahout.clustering.iterator.ClusterWritable; //导入方法依赖的package包/类
public void writeToSeqFiles(Path path) throws IOException {
  writePolicy(policy, path);
  Configuration config = new Configuration();
  FileSystem fs = FileSystem.get(path.toUri(), config);
  SequenceFile.Writer writer = null;
  ClusterWritable cw = new ClusterWritable();
  for (int i = 0; i < models.size(); i++) {
    try {
      Cluster cluster = models.get(i);
      cw.setValue(cluster);
      writer = new SequenceFile.Writer(fs, config,
          new Path(path, "part-" + String.format(Locale.ENGLISH, "%05d", i)), IntWritable.class,
          ClusterWritable.class);
      Writable key = new IntWritable(i);
      writer.append(key, cw);
    } finally {
      Closeables.closeQuietly(writer);
    }
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:21,代码来源:ClusterClassifier.java

示例3: createCanopyFromVectorsSeq

import org.apache.mahout.clustering.iterator.ClusterWritable; //导入方法依赖的package包/类
/**
 * Convert vectors to MeanShiftCanopies sequentially
 * 
 * @param input
 *          the Path to the input VectorWritable data
 * @param output
 *          the Path to the initial clusters directory
 * @param measure
 *          the DistanceMeasure
 */
private static void createCanopyFromVectorsSeq(Path input, Path output,
    DistanceMeasure measure) throws IOException {
  Configuration conf = new Configuration();
  FileSystem fs = FileSystem.get(input.toUri(), conf);
  FileStatus[] status = fs.listStatus(input, PathFilters.logsCRCFilter());
  int part = 0;
  int id = 0;
  for (FileStatus s : status) {
    SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, new Path(
        output, "part-m-" + part++), Text.class, ClusterWritable.class);
    try {
      for (VectorWritable value : new SequenceFileValueIterable<VectorWritable>(
          s.getPath(), conf)) {
        MeanShiftCanopy initialCanopy = MeanShiftCanopy.initialCanopy(value.get(),
		      id++, measure);
        ClusterWritable clusterWritable = new ClusterWritable();
        clusterWritable.setValue(initialCanopy);
  writer.append(new Text(), clusterWritable);
      }
    } finally {
      Closeables.closeQuietly(writer);
    }
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:35,代码来源:MeanShiftCanopyDriver.java

示例4: buildClustersSeq

import org.apache.mahout.clustering.iterator.ClusterWritable; //导入方法依赖的package包/类
/**
 * Build a directory of Canopy clusters from the input vectors and other
 * arguments. Run sequential execution
 * 
 * @param input
 *          the Path to the directory containing input vectors
 * @param output
 *          the Path for all output directories
 * @param measure
 *          the DistanceMeasure
 * @param t1
 *          the double T1 distance metric
 * @param t2
 *          the double T2 distance metric
 * @param clusterFilter
 *          the int minimum size of canopies produced
 * @return the canopy output directory Path
 */
private static Path buildClustersSeq(Path input, Path output,
    DistanceMeasure measure, double t1, double t2, int clusterFilter)
    throws IOException {
  CanopyClusterer clusterer = new CanopyClusterer(measure, t1, t2);
  Collection<Canopy> canopies = Lists.newArrayList();
  Configuration conf = new Configuration();
  FileSystem fs = FileSystem.get(input.toUri(), conf);

  for (VectorWritable vw : new SequenceFileDirValueIterable<VectorWritable>(
      input, PathType.LIST, PathFilters.logsCRCFilter(), conf)) {
    clusterer.addPointToCanopies(vw.get(), canopies);
  }

  Path canopyOutputDir = new Path(output, Cluster.CLUSTERS_DIR + '0'+ Cluster.FINAL_ITERATION_SUFFIX);
  Path path = new Path(canopyOutputDir, "part-r-00000");
  SequenceFile.Writer writer = new SequenceFile.Writer(fs, conf, path,
      Text.class, ClusterWritable.class);
  ClusterWritable clusterWritable = new ClusterWritable();
  try {
    for (Canopy canopy : canopies) {
      canopy.computeParameters();
      if (log.isDebugEnabled()) {
        log.debug("Writing Canopy:{} center:{} numPoints:{} radius:{}",
            new Object[] { canopy.getIdentifier(),
                AbstractCluster.formatVector(canopy.getCenter(), null),
                canopy.getNumObservations(),
                AbstractCluster.formatVector(canopy.getRadius(), null) });
      }
      if (canopy.getNumObservations() > clusterFilter) {
      	clusterWritable.setValue(canopy);
      	writer.append(new Text(canopy.getIdentifier()), clusterWritable);
      }
    }
  } finally {
    Closeables.closeQuietly(writer);
  }
  return canopyOutputDir;
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:57,代码来源:CanopyDriver.java

示例5: map

import org.apache.mahout.clustering.iterator.ClusterWritable; //导入方法依赖的package包/类
@Override
protected void map(WritableComparable<?> key, VectorWritable point, Context context)
  throws IOException, InterruptedException {
  MeanShiftCanopy canopy = MeanShiftCanopy.initialCanopy(point.get(), nextCanopyId++, measure);
  ClusterWritable clusterWritable = new ClusterWritable();
  clusterWritable.setValue(canopy);
  context.write(new Text(key.toString()), clusterWritable);
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:9,代码来源:MeanShiftCanopyCreatorMapper.java

示例6: cleanup

import org.apache.mahout.clustering.iterator.ClusterWritable; //导入方法依赖的package包/类
@Override
protected void cleanup(Context context) throws IOException, InterruptedException {
  int reducer = 0;
  for (MeanShiftCanopy canopy : canopies) {
    clusterer.shiftToMean(canopy);
    ClusterWritable clusterWritable = new ClusterWritable();
    clusterWritable.setValue(canopy);
    context.write(new Text(String.valueOf(reducer)), clusterWritable);
    reducer++;
    if (reducer >= numReducers) {
      reducer = 0;
    }
  }
  super.cleanup(context);
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:16,代码来源:MeanShiftCanopyMapper.java


注:本文中的org.apache.mahout.clustering.iterator.ClusterWritable.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。