/** * Adds all the data elements in the Searcher. * * @param data an iterable of WeightedVectors to add. */ public void addAll(Iterable<? extends Vector> data) { for (Vector vector : data) { add(vector); } }
/** * @return the number of clusters computed from the points until now. */ public int getNumClusters() { return centroids.size(); }
public HashedVector(Vector vector, Matrix projection, int index, long mask) { super(vector, 1, index); this.hash = mask & computeHash64(vector, projection); }
/** * Adds up the distances from each point to its closest cluster and returns the sum. * @param datapoints iterable of datapoints. * @param centroids iterable of Centroids. * @return the total cost described above. */ public static double totalClusterCost(Iterable<? extends Vector> datapoints, Iterable<? extends Vector> centroids) { DistanceMeasure distanceMeasure = new EuclideanDistanceMeasure(); UpdatableSearcher searcher = new ProjectionSearch(distanceMeasure, 3, 1); searcher.addAll(centroids); return totalClusterCost(datapoints, searcher); }
@Override public void add(Vector vector) { initialize(vector.size()); trainingVectors.add(new HashedVector(vector, projection, HashedVector.INVALID_INDEX, BIT_MASK)); }
@Parameterized.Parameters public static List<Object[]> generateData() { RandomUtils.useTestSeed(); Matrix dataPoints = multiNormalRandomData(NUM_DATA_POINTS, NUM_DIMENSIONS); return Arrays.asList(new Object[][]{ {new ProjectionSearch(new EuclideanDistanceMeasure(), NUM_PROJECTIONS, SEARCH_SIZE), dataPoints}, {new FastProjectionSearch(new EuclideanDistanceMeasure(), NUM_PROJECTIONS, SEARCH_SIZE), dataPoints}, {new LocalitySensitiveHashSearch(new EuclideanDistanceMeasure(), SEARCH_SIZE), dataPoints}, }); }
public DistanceMeasure getDistanceMeasure() { return centroids.getDistanceMeasure(); } }
public static HashedVector hash(WeightedVector v, Matrix projection) { return hash(v, projection, 0); }
public static HashedVector hash(WeightedVector v, Matrix projection, long mask) { return new HashedVector(v, projection, mask); }
/** * Adds all the data elements in the Searcher. * * @param data an iterable of WeightedVectors to add. */ public void addAll(Iterable<? extends Vector> data) { for (Vector vector : data) { add(vector); } }
/** * @return the number of clusters computed from the points until now. */ public int getNumClusters() { return centroids.size(); }
public HashedVector(Vector vector, Matrix projection, int index, long mask) { super(vector, 1, index); this.hash = mask & computeHash64(vector, projection); }
public DistanceMeasure getDistanceMeasure() { return centroids.getDistanceMeasure(); } }
public static HashedVector hash(WeightedVector v, Matrix projection) { return hash(v, projection, 0); }
public static HashedVector hash(WeightedVector v, Matrix projection, long mask) { return new HashedVector(v, projection, mask); }
/** * Adds all the data elements in the Searcher. * * @param data an iterable of WeightedVectors to add. */ public void addAll(Iterable<? extends Vector> data) { for (Vector vector : data) { add(vector); } }
/** * @return the number of clusters computed from the points until now. */ public int getNumClusters() { return centroids.size(); }
public HashedVector(Vector vector, Matrix projection, int index, long mask) { super(vector, 1, index); this.hash = mask & computeHash64(vector, projection); }
public DistanceMeasure getDistanceMeasure() { return centroids.getDistanceMeasure(); } }
public static HashedVector hash(WeightedVector v, Matrix projection) { return hash(v, projection, 0); }