Package org.apache.mahout.clustering

Examples of org.apache.mahout.clustering.WeightedVectorWritable


    throws IOException, InterruptedException {
    for (int i = 0; i < clusters.size(); i++) {
      double pdf = pi.get(i);
      if (pdf > threshold && clusters.get(i).getTotalCount() > 0) {
        //System.out.println(i + ": " + ClusterBase.formatVector(vector.get(), null));
        context.write(new IntWritable(i), new WeightedVectorWritable(pdf, point.get()));
      }
    }
  }
View Full Code Here


    throws IOException {
    for (int i = 0; i < clusters.size(); i++) {
      double pdf = pi.get(i);
      if (pdf > threshold && clusters.get(i).getTotalCount() > 0) {
        //System.out.println(i + ": " + ClusterBase.formatVector(vector.get(), null));
        writer.append(new IntWritable(i), new WeightedVectorWritable(pdf, vector.get()));
      }
    }
  }
View Full Code Here

        maxPdf = pdf;
        clusterId = i;
      }
    }
    //System.out.println(i + ": " + ClusterBase.formatVector(vector.get(), null));
    writer.append(new IntWritable(clusterId), new WeightedVectorWritable(maxPdf, vector.get()));
  }
View Full Code Here

      try {
        for (Pair<Writable,MeanShiftCanopy> record
             : new SequenceFileIterable<Writable,MeanShiftCanopy>(s.getPath(), conf)) {
          MeanShiftCanopy canopy = record.getSecond();
          MeanShiftCanopy closest = MeanShiftCanopyClusterer.findCoveringCanopy(canopy, clusters);
          writer.append(new IntWritable(closest.getId()), new WeightedVectorWritable(1, canopy.getCenter()));
        }
      } finally {
        writer.close();
      }
    }
View Full Code Here

                              WeightedVectorWritable point,
                              DistanceMeasure measure,
                              Map<Integer, List<VectorWritable>> representativePoints,
                              Map<Integer, WeightedVectorWritable> mostDistantPoints) {
    int key = clusterId.get();
    WeightedVectorWritable currentMDP = mostDistantPoints.get(key);

    List<VectorWritable> repPoints = representativePoints.get(key);
    double totalDistance = 0.0;
    for (VectorWritable refPoint : repPoints) {
      totalDistance += measure.distance(refPoint.get(), point.getVector());
    }
    if (currentMDP == null || currentMDP.getWeight() < totalDistance) {
      mostDistantPoints.put(key, new WeightedVectorWritable(totalDistance, point.getVector().clone()));
    }
  }
View Full Code Here

  @Override
  protected void reduce(IntWritable key, Iterable<WeightedVectorWritable> values, Context context)
    throws IOException, InterruptedException {
    // find the most distant point
    WeightedVectorWritable mdp = null;
    for (WeightedVectorWritable dpw : values) {
      if (mdp == null || mdp.getWeight() < dpw.getWeight()) {
        mdp = new WeightedVectorWritable(dpw.getWeight(), dpw.getVector());
      }
    }
    context.write(new IntWritable(key.get()), new VectorWritable(mdp.getVector()));
  }
View Full Code Here

        List<WeightedVectorWritable> points = clusterIdToPoints.get(value.getId());
        if (points != null) {
          writer.write("\tWeight:  Point:\n\t");
          for (Iterator<WeightedVectorWritable> iterator = points.iterator(); iterator.hasNext();) {
            WeightedVectorWritable point = iterator.next();
            writer.write(String.valueOf(point.getWeight()));
            writer.write(": ");
            writer.write(AbstractCluster.formatVector(point.getVector(), dictionary));
            if (iterator.hasNext()) {
              writer.write("\n\t");
            }
          }
          writer.write('\n');
View Full Code Here

      List<WeightedVectorWritable> list = pointClusterInfo.get(clusterId);
      if (list == null) {
        list = new ArrayList<WeightedVectorWritable>();
        pointClusterInfo.put(clusterId, list);
      }
      list.add(new WeightedVectorWritable(clusterPdf, point));
      double totalProb = 0;
      for (int i = 0; i < clusterList.size(); i++) {
        //SoftCluster cluster = clusterList.get(i);
        double probWeight = clusterer.computeProbWeight(clusterDistanceList.get(i), clusterDistanceList);
        totalProb += probWeight;
View Full Code Here

  public void emitPointToClosestCanopy(Vector point,
                                       Iterable<Canopy> canopies,
                                       Mapper<?,?,IntWritable,WeightedVectorWritable>.Context context)
    throws IOException, InterruptedException {
    Canopy closest = findClosestCanopy(point, canopies);
    context.write(new IntWritable(closest.getId()), new WeightedVectorWritable(1, point));
    context.setStatus("Emit Closest Canopy ID:" + closest.getIdentifier());
  }
View Full Code Here

    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()));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.mahout.clustering.WeightedVectorWritable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.