Package org.apache.mahout.knn.search

Examples of org.apache.mahout.knn.search.BruteSearch.search()


          new DenseVector(new double[]{0.125 * (i & 4), i & 2, i & 1}), 1, i));
      searcher.add(referenceVectors.get(referenceVectors.size() - 1));
    }

    final List<List<WeightedThing<Vector>>> searchResults =
        searcher.search(referenceVectors, 3);
    for (List<WeightedThing<Vector>> r : searchResults) {
      assertEquals(0, r.get(0).getWeight(), 1e-8);
      assertEquals(0.5, r.get(1).getWeight(), 1e-8);
      assertEquals(1, r.get(2).getWeight(), 1e-8);
    }
View Full Code Here


    for (int threads : new int[]{1, 2, 3, 4, 5, 6, 10, 20, 50}) {
      for (int block : new int[]{1, 10, 50}) {
        BruteSearch search = new BruteSearch(new EuclideanDistanceMeasure());
        search.addAll(referenceVectors);
        long t0 = System.nanoTime();
        search.search(queryVectors, block, threads);
        long t1 = System.nanoTime();
        System.out.printf("%d\t%d\t%.2f\n", threads, block, (t1 - t0) / 1e9);
      }
    }
  }
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.