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


Java WeightedVectorWritable类代码示例

本文整理汇总了Java中org.apache.mahout.clustering.classify.WeightedVectorWritable的典型用法代码示例。如果您正苦于以下问题:Java WeightedVectorWritable类的具体用法?Java WeightedVectorWritable怎么用?Java WeightedVectorWritable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: process

import org.apache.mahout.clustering.classify.WeightedVectorWritable; //导入依赖的package包/类
/**
 * This method takes the clustered points output by the clustering algorithms as input and writes them into
 * their respective clusters.
 */
public void process() throws IOException {
  createPostProcessDirectory();
  for (Pair<?,WeightedVectorWritable> record : 
       new SequenceFileDirIterable<Writable,WeightedVectorWritable>(clusteredPoints,
                                                                    PathType.GLOB,
                                                                    PathFilters.partFilter(),
                                                                    null,
                                                                    false,
                                                                    conf)) {
    String clusterId = record.getFirst().toString().trim();
    putVectorInRespectiveCluster(clusterId, record.getSecond());
  }
  IOUtils.close(writersForClusters.values());
  writersForClusters.clear();
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:20,代码来源:ClusterOutputPostProcessor.java

示例2: clusterDataMR

import org.apache.mahout.clustering.classify.WeightedVectorWritable; //导入依赖的package包/类
/**
 * Cluster the data using Hadoop
 */
private static void clusterDataMR(Path input, Path clustersIn, Path output)
    throws IOException, InterruptedException, ClassNotFoundException {
  Configuration conf = new Configuration();
  conf.set(STATE_IN_KEY, clustersIn.toString());
  Job job = new Job(conf,
      "Mean Shift Driver running clusterData over input: " + input);
  job.setOutputKeyClass(IntWritable.class);
  job.setOutputValueClass(WeightedVectorWritable.class);
  job.setMapperClass(MeanShiftCanopyClusterMapper.class);

  job.setInputFormatClass(SequenceFileInputFormat.class);
  job.setOutputFormatClass(SequenceFileOutputFormat.class);
  job.setNumReduceTasks(0);
  job.setJarByClass(MeanShiftCanopyDriver.class);

  FileInputFormat.setInputPaths(job, input);
  FileOutputFormat.setOutputPath(job, output);

  if (!job.waitForCompletion(true)) {
    throw new InterruptedException(
        "Mean Shift Clustering failed on clustersIn " + clustersIn);
  }
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:27,代码来源:MeanShiftCanopyDriver.java

示例3: putVectorInRespectiveCluster

import org.apache.mahout.clustering.classify.WeightedVectorWritable; //导入依赖的package包/类
/**
 * 
 * Finds out the cluster directory of the vector and writes it into the specified cluster.
 */
private void putVectorInRespectiveCluster(String clusterId, WeightedVectorWritable point) throws IOException {
  Writer writer = findWriterForVector(clusterId);
  postProcessedClusterDirectories.put(clusterId,
                                      PathDirectory.getClusterPathForClusterId(clusterPostProcessorOutput, clusterId));
  writeVectorToCluster(writer, point);
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:11,代码来源:ClusterOutputPostProcessor.java

示例4: map

import org.apache.mahout.clustering.classify.WeightedVectorWritable; //导入依赖的package包/类
@Override
 protected void map(WritableComparable<?> key, ClusterWritable clusterWritable, Context context)
   throws IOException, InterruptedException {
   // canopies use canopyIds assigned when input vectors are processed as vectorIds too
MeanShiftCanopy canopy = (MeanShiftCanopy)clusterWritable.getValue();
   int vectorId = canopy.getId();
   for (MeanShiftCanopy msc : canopies) {
     for (int containedId : msc.getBoundPoints().toList()) {
       if (vectorId == containedId) {
         context.write(new IntWritable(msc.getId()),
                        new WeightedVectorWritable(1, canopy.getCenter()));
       }
     }
   }
 }
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:16,代码来源:MeanShiftCanopyClusterMapper.java

示例5: map

import org.apache.mahout.clustering.classify.WeightedVectorWritable; //导入依赖的package包/类
/**
 * The key is the cluster id and the value is the vector.
 */
@Override
protected void map(IntWritable key, WeightedVectorWritable vector, Context context) throws IOException,
                                                                                   InterruptedException {
  context.write(new Text(key.toString().trim()), new VectorWritable(vector.getVector()));
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:9,代码来源:ClusterOutputPostProcessorMapper.java

示例6: writeVectorToCluster

import org.apache.mahout.clustering.classify.WeightedVectorWritable; //导入依赖的package包/类
/**
 * Writes vector to the cluster directory.
 */
private void writeVectorToCluster(Writer writer, WeightedVectorWritable point) throws IOException {
  writer.append(new LongWritable(uniqueVectorId++), new VectorWritable(point.getVector()));
  writer.sync();
}
 
开发者ID:saradelrio,项目名称:Chi-FRBCS-BigDataCS,代码行数:8,代码来源:ClusterOutputPostProcessor.java


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