@Test public void testMeanShift() { ThreadedContext random = new ThreadedContext(123, 4); Pair<List<Clusterable>, List<Integer>> blobs = makeBlobs(1000, of(new ClusterablePoint(1, 1), new ClusterablePoint(-1, -1), new ClusterablePoint(1, -1)), 0.6, true, random.getRandomForThread()); double bandwidth = MeanShiftUtils.estimateBandwidth(blobs.first(), 0.2, 100, random.getRandomForThread()); assertEquals(0.9445823374425488, bandwidth, EPS); MeanShift<Clusterable> meanShift = new MeanShift<>(new GaussianKernel(), new EuclideanDistance(), bandwidth); List<CentroidCluster<Clusterable>> clusters = meanShift.cluster(blobs.first(), random); assertEquals(3, clusters.size()); assertArrayEquals(new ClusterablePoint(0.9355921828887271, -0.8826555282415418).getPoint(), clusters.get(0).getCenter().getPoint(), EPS); assertEquals(339, clusters.get(0).getPoints().size()); assertArrayEquals(new ClusterablePoint(-1.0194373051398684, -0.983789596998387).getPoint(), clusters.get(1).getCenter().getPoint(), EPS); assertEquals(330, clusters.get(1).getPoints().size()); assertArrayEquals(new ClusterablePoint(0.9247381214268715, 0.9442266587978521).getPoint(), clusters.get(2).getCenter().getPoint(), EPS); assertEquals(332, clusters.get(2).getPoints().size()); }
public MeanShift(Kernel kernel, DistanceMetric metric) { this(kernel, metric, NEGATIVE_INFINITY, DEFAULT_MAX_ITERATIONS, new PointSeed()); }
MeanShift implements Clusterer<T> { public MeanShift(Kernel kernel, DistanceMetric metric) { this(kernel, metric, NEGATIVE_INFINITY, DEFAULT_MAX_ITERATIONS, new PointSeed()); } }
MeanShift implements Clusterer<T> { public MeanShift(Kernel kernel, DistanceMetric metric) { this(kernel, metric, NEGATIVE_INFINITY, DEFAULT_MAX_ITERATIONS, new PointSeed()); } MeanShift(Kernel kernel, DistanceMetric metric);  MeanShift(Kernel kernel, DistanceMetric metric, SeedingStrategy seed);  MeanShift(Kernel kernel, DistanceMetric metric, double window);  MeanShift(Kernel kernel, DistanceMetric metric, int iterations);  MeanShift(Kernel kernel, DistanceMetric metric, double window, int iterations, SeedingStrategy initSeeds); }
MeanShift implements Clusterer<T> { public MeanShift(Kernel kernel, DistanceMetric metric) { this(kernel, metric, NEGATIVE_INFINITY, DEFAULT_MAX_ITERATIONS, new PointSeed()); } MeanShift(Kernel kernel, DistanceMetric metric);  MeanShift(Kernel kernel, DistanceMetric metric, SeedingStrategy seed);  MeanShift(Kernel kernel, DistanceMetric metric, double window);  MeanShift(Kernel kernel, DistanceMetric metric, int iterations);  MeanShift(Kernel kernel, DistanceMetric metric, double window, int iterations, SeedingStrategy initSeeds); @Override List<CentroidCluster<T>> cluster(Collection<T> points, ThreadedContext context); }
MeanShift implements Clusterer<T> { public MeanShift(Kernel kernel, DistanceMetric metric) { this(kernel, metric, NEGATIVE_INFINITY, DEFAULT_MAX_ITERATIONS, new PointSeed()); } MeanShift(Kernel kernel, DistanceMetric metric);  MeanShift(Kernel kernel, DistanceMetric metric, SeedingStrategy seed);  MeanShift(Kernel kernel, DistanceMetric metric, double window);  MeanShift(Kernel kernel, DistanceMetric metric, int iterations);  MeanShift(Kernel kernel, DistanceMetric metric, double window, int iterations, SeedingStrategy initSeeds); @Override List<CentroidCluster<T>> cluster(Collection<T> points, ThreadedContext context);  }