Examples of SquaredEuclideanDistanceMeasure


Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

    new TimesBenchmark(mark).benchmark();
    new SerializationBenchmark(mark).benchmark();

    DistanceBenchmark distanceBenchmark = new DistanceBenchmark(mark);
    distanceBenchmark.benchmark(new CosineDistanceMeasure());
    distanceBenchmark.benchmark(new SquaredEuclideanDistanceMeasure());
    distanceBenchmark.benchmark(new EuclideanDistanceMeasure());
    distanceBenchmark.benchmark(new ManhattanDistanceMeasure());
    distanceBenchmark.benchmark(new TanimotoDistanceMeasure());
    distanceBenchmark.benchmark(new ChebyshevDistanceMeasure());
    distanceBenchmark.benchmark(new MinkowskiDistanceMeasure());

    if (mark.numClusters > 0) {
      ClosestCentroidBenchmark centroidBenchmark = new ClosestCentroidBenchmark(mark);
      centroidBenchmark.benchmark(new CosineDistanceMeasure());
      centroidBenchmark.benchmark(new SquaredEuclideanDistanceMeasure());
      centroidBenchmark.benchmark(new EuclideanDistanceMeasure());
      centroidBenchmark.benchmark(new ManhattanDistanceMeasure());
      centroidBenchmark.benchmark(new TanimotoDistanceMeasure());
      centroidBenchmark.benchmark(new ChebyshevDistanceMeasure());
      centroidBenchmark.benchmark(new MinkowskiDistanceMeasure());
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

      mark.cloneBenchmark();
      mark.dotBenchmark();
      mark.serializeBenchmark();
      mark.deserializeBenchmark();
      mark.distanceMeasureBenchmark(new CosineDistanceMeasure());
      mark.distanceMeasureBenchmark(new SquaredEuclideanDistanceMeasure());
      mark.distanceMeasureBenchmark(new EuclideanDistanceMeasure());
      mark.distanceMeasureBenchmark(new ManhattanDistanceMeasure());
      mark.distanceMeasureBenchmark(new TanimotoDistanceMeasure());
     
      mark.closestCentroidBenchmark(new CosineDistanceMeasure());
      mark.closestCentroidBenchmark(new SquaredEuclideanDistanceMeasure());
      mark.closestCentroidBenchmark(new EuclideanDistanceMeasure());
      mark.closestCentroidBenchmark(new ManhattanDistanceMeasure());
      mark.closestCentroidBenchmark(new TanimotoDistanceMeasure());
     
      log.info("\n{}", mark);
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

          new SequenceFileDirValueIterable<VectorWritable>(new Path(trainFile), PathType.GLOB, conf);
      Iterable<Vector> trainDatapoints = IOUtils.getVectorsFromVectorWritableIterable(trainIterable);
      Iterable<Vector> datapoints = trainDatapoints;

      printSummaries(ClusteringUtils.summarizeClusterDistances(trainDatapoints, centroids,
          new SquaredEuclideanDistanceMeasure()), "train");

      // Also adding in the "test" set.
      if (testFile != null) {
        SequenceFileDirValueIterable<VectorWritable> testIterable =
            new SequenceFileDirValueIterable<VectorWritable>(new Path(testFile), PathType.GLOB, conf);
        Iterable<Vector> testDatapoints = IOUtils.getVectorsFromVectorWritableIterable(testIterable);

        printSummaries(ClusteringUtils.summarizeClusterDistances(testDatapoints, centroids,
            new SquaredEuclideanDistanceMeasure()), "test");

        datapoints = Iterables.concat(trainDatapoints, testDatapoints);
      }

      // At this point, all train/test CSVs have been written. We now compute quality metrics.
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure


  @Test
  public void testClusteringMultipleRuns() {
    for (int i = 1; i <= 10; ++i) {
      BallKMeans clusterer = new BallKMeans(new BruteSearch(new SquaredEuclideanDistanceMeasure()),
          1 << NUM_DIMENSIONS, NUM_ITERATIONS, true, i);
      clusterer.cluster(syntheticData.getFirst());
      double costKMeansPlusPlus = ClusteringUtils.totalClusterCost(syntheticData.getFirst(), clusterer);

      clusterer = new BallKMeans(new BruteSearch(new SquaredEuclideanDistanceMeasure()),
          1 << NUM_DIMENSIONS, NUM_ITERATIONS, false, i);
      clusterer.cluster(syntheticData.getFirst());
      double costKMeansRandom = ClusteringUtils.totalClusterCost(syntheticData.getFirst(), clusterer);

      System.out.printf("%d runs; kmeans++: %f; random: %f\n", i, costKMeansPlusPlus, costKMeansRandom);
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

    }
  }

  @Test
  public void testClustering() {
    UpdatableSearcher searcher = new BruteSearch(new SquaredEuclideanDistanceMeasure());
    BallKMeans clusterer = new BallKMeans(searcher, 1 << NUM_DIMENSIONS, NUM_ITERATIONS);

    long startTime = System.currentTimeMillis();
    Pair<List<Centroid>, List<Centroid>> data = syntheticData;
    clusterer.cluster(data.getFirst());
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

  public void testInitialization() {
    // Start with super clusterable data.
    List<? extends WeightedVector> data = cubishTestData(0.01);

    // Just do initialization of ball k-means. This should drop a point into each of the clusters.
    BallKMeans r = new BallKMeans(new BruteSearch(new SquaredEuclideanDistanceMeasure()), 6, 20);
    r.cluster(data);

    // Put the centroids into a matrix.
    Matrix x = new DenseMatrix(6, 5);
    int row = 0;
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

        mapDriver.getConfiguration().get(StreamingKMeansDriver.SEARCHER_CLASS_OPTION));
    for (Centroid datapoint : syntheticData.getFirst()) {
      mapDriver.addInput(new IntWritable(0), new VectorWritable(datapoint));
    }
    List<org.apache.hadoop.mrunit.types.Pair<IntWritable,CentroidWritable>> results = mapDriver.run();
    BruteSearch resultSearcher = new BruteSearch(new SquaredEuclideanDistanceMeasure());
    for (org.apache.hadoop.mrunit.types.Pair<IntWritable, CentroidWritable> result : results) {
      resultSearcher.add(result.getSecond().getCentroid());
    }
    System.out.printf("Clustered the data into %d clusters\n", results.size());
    for (Vector mean : syntheticData.getSecond()) {
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

  }

  @Parameters
  public static List<Object[]> generateData() {
    return Arrays.asList(new Object[][] {
        {new ProjectionSearch(new SquaredEuclideanDistanceMeasure(), NUM_PROJECTIONS, SEARCH_SIZE), true},
        {new FastProjectionSearch(new SquaredEuclideanDistanceMeasure(), NUM_PROJECTIONS, SEARCH_SIZE),
            true},
        {new ProjectionSearch(new SquaredEuclideanDistanceMeasure(), NUM_PROJECTIONS, SEARCH_SIZE), false},
        {new FastProjectionSearch(new SquaredEuclideanDistanceMeasure(), NUM_PROJECTIONS, SEARCH_SIZE),
            false},
    });
  }
View Full Code Here

Examples of org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure

      mark.cloneBenchmark();
      mark.dotBenchmark();
      mark.serializeBenchmark();
      mark.deserializeBenchmark();
      mark.distanceMeasureBenchmark(new CosineDistanceMeasure());
      mark.distanceMeasureBenchmark(new SquaredEuclideanDistanceMeasure());
      mark.distanceMeasureBenchmark(new EuclideanDistanceMeasure());
      mark.distanceMeasureBenchmark(new ManhattanDistanceMeasure());
      mark.distanceMeasureBenchmark(new TanimotoDistanceMeasure());
     
      mark.closestCentroidBenchmark(new CosineDistanceMeasure());
      mark.closestCentroidBenchmark(new SquaredEuclideanDistanceMeasure());
      mark.closestCentroidBenchmark(new EuclideanDistanceMeasure());
      mark.closestCentroidBenchmark(new ManhattanDistanceMeasure());
      mark.closestCentroidBenchmark(new TanimotoDistanceMeasure());
     
      log.info("\n{}", mark);
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.