Examples of Centroid


Examples of org.apache.mahout.math.Centroid

    return Iterables.transform(dirIterable, new Function<ClusterWritable, Centroid>() {
      int numClusters = 0;
      @Override
      public Centroid apply(ClusterWritable input) {
        Preconditions.checkNotNull(input);
        return new Centroid(numClusters++, input.getValue().getCenter().clone(),
            input.getValue().getTotalObservations());
      }
    });
  }
View Full Code Here

Examples of org.apache.mahout.math.Centroid

    Iterator<Centroid> dataPointsIterator = dataPoints.iterator();

    if (estimateDistanceCutoff == StreamingKMeansDriver.INVALID_DISTANCE_CUTOFF) {
      List<Centroid> estimatePoints = Lists.newArrayListWithExpectedSize(NUM_ESTIMATE_POINTS);
      while (dataPointsIterator.hasNext() && estimatePoints.size() < NUM_ESTIMATE_POINTS) {
        Centroid centroid = dataPointsIterator.next();
        estimatePoints.add(centroid);
      }

      if (log.isInfoEnabled()) {
        log.info("Estimated Points: {}", estimatePoints.size());
View Full Code Here

Examples of org.apache.mahout.math.Centroid

    estimateDistanceCutoff = false;
  }

  @Override
  public void map(Writable key, VectorWritable point, Context context) {
    Centroid centroid = new Centroid(numPoints++, point.get(), 1);
    if (estimateDistanceCutoff) {
      if (numPoints < NUM_ESTIMATE_POINTS) {
        estimatePoints.add(centroid);
      } else if (numPoints == NUM_ESTIMATE_POINTS) {
        clusterEstimatePoints();
View Full Code Here

Examples of org.apache.mahout.math.Centroid

    SequenceFile.Writer writer = SequenceFile.createWriter(FileSystem.get(conf), conf, new Path(output, "part-r-00000"), IntWritable.class,
        CentroidWritable.class);
    int numCentroids = 0;
    // Run BallKMeans on the intermediate centroids.
    for (Vector finalVector : StreamingKMeansReducer.getBestCentroids(intermediateCentroids, conf)) {
      Centroid finalCentroid = (Centroid)finalVector;
      writer.append(new IntWritable(numCentroids++), new CentroidWritable(finalCentroid));
    }
    writer.close();
    long end = System.currentTimeMillis();
    log.info("Finished BallKMeans. Took {}.", (end - start) / 1000.0);
View Full Code Here

Examples of org.apache.mahout.math.Centroid

    return Iterables.transform(dirIterable, new Function<ClusterWritable, Centroid>() {
      int numClusters = 0;
      @Override
      public Centroid apply(ClusterWritable input) {
        Preconditions.checkNotNull(input);
        return new Centroid(numClusters++, input.getValue().getCenter().clone(),
            input.getValue().getTotalObservations());
      }
    });
  }
View Full Code Here

Examples of org.apache.mahout.math.Centroid

    }
    for (int i = 0; i < searcher.size(); ++i) {
      summarizers.add(new OnlineSummarizer());
    }
    for (Vector v : datapoints) {
      Centroid closest = (Centroid)searcher.search(v,  1).get(0).getValue();
      OnlineSummarizer summarizer = summarizers.get(closest.getIndex());
      summarizer.add(distanceMeasure.distance(v, closest));
    }
    return summarizers;
  }
View Full Code Here

Examples of org.apache.mahout.math.Centroid

      int pow2J = 1 << (numDimensions - 1);
      for (int j = 0; j < numDimensions; ++j) {
        v.set(j, 1.0 / pow2J * (i & pow2J));
        pow2J >>= 1;
      }
      mean.add(new Centroid(i, v, 1));
      rowSamplers.add(new MultiNormal(distributionRadius, v));
    }

    // Sample the requested number of data points.
    List<Centroid> data = Lists.newArrayListWithCapacity(numDatapoints);
    for (int i = 0; i < numDatapoints; ++i) {
      data.add(new Centroid(i, rowSamplers.get(i % pow2N).sample(), 1));
    }
    return new Pair<List<Centroid>, List<Centroid>>(data, mean);
  }
View Full Code Here

Examples of org.apache.mahout.math.Centroid

    }
    for (int i = 0; i < searcher.size(); ++i) {
      summarizers.add(new OnlineSummarizer());
    }
    for (Vector v : datapoints) {
      Centroid closest = (Centroid)searcher.search(v,  1).get(0).getValue();
      OnlineSummarizer summarizer = summarizers.get(closest.getIndex());
      summarizer.add(distanceMeasure.distance(v, closest));
    }
    return summarizers;
  }
View Full Code Here

Examples of org.neo4j.gis.spatial.pipes.processing.Centroid

   
    /**
     * @see Centroid
     */
    public GeoPipeline toCentroid() {
      return addPipe(new Centroid());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.