Search in sources :

Example 1 with LongCentroid

use of org.locationtech.geowave.analytic.clustering.LongCentroid in project geowave by locationtech.

the class StripWeakCentroidsRunnerTest method testStable1.

@Test
public void testStable1() throws Exception {
    final List<AnalyticItemWrapper<Long>> list = new ArrayList<>();
    final int[] cnts = new int[] { 1000, 851, 750, 650, 525, 200, 100, 90, 70 };
    for (int i = 0; i < cnts.length; i++) {
        list.add(new LongCentroid(i, "", cnts[i]));
    }
    final StableChangeBreakStrategy<Long> breakS = new StableChangeBreakStrategy<>();
    assertEquals(5, breakS.getBreakPoint(list));
}
Also used : LongCentroid(org.locationtech.geowave.analytic.clustering.LongCentroid) ArrayList(java.util.ArrayList) StableChangeBreakStrategy(org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.StableChangeBreakStrategy) TailStableChangeBreakStrategy(org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.TailStableChangeBreakStrategy) AnalyticItemWrapper(org.locationtech.geowave.analytic.AnalyticItemWrapper) Test(org.junit.Test)

Example 2 with LongCentroid

use of org.locationtech.geowave.analytic.clustering.LongCentroid in project geowave by locationtech.

the class StripWeakCentroidsRunnerTest method testMaxUniform.

@Test
public void testMaxUniform() throws Exception {
    final List<AnalyticItemWrapper<Long>> list = new ArrayList<>();
    final int[] cnts = new int[] { 1000, 851, 750, 650, 525, 200, 90, 70 };
    for (int i = 0; i < cnts.length; i++) {
        list.add(new LongCentroid(i, "", cnts[i]));
    }
    final TailMaxBreakStrategy<Long> breakS = new TailMaxBreakStrategy<>();
    assertEquals(5, breakS.getBreakPoint(list));
}
Also used : LongCentroid(org.locationtech.geowave.analytic.clustering.LongCentroid) TailMaxBreakStrategy(org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.TailMaxBreakStrategy) ArrayList(java.util.ArrayList) AnalyticItemWrapper(org.locationtech.geowave.analytic.AnalyticItemWrapper) Test(org.junit.Test)

Example 3 with LongCentroid

use of org.locationtech.geowave.analytic.clustering.LongCentroid in project geowave by locationtech.

the class CentroidAssociationFnTest method test.

@Test
public void test() {
    final CentroidAssociationFn<Long> fn = new CentroidAssociationFn<>();
    fn.setDistanceFunction(new DistanceFn<Long>() {

        /**
         */
        private static final long serialVersionUID = 1L;

        @Override
        public double measure(final Long x, final Long y) {
            return Math.abs(x.longValue() - y.longValue());
        }
    });
    final List<AnalyticItemWrapper<Long>> dataSet = Arrays.asList((AnalyticItemWrapper<Long>) new LongCentroid(345, "", 0), new LongCentroid(764, "", 0), new LongCentroid(89, "", 0), new LongCentroid(900, "", 0));
    final List<AnalyticItemWrapper<Long>> centroidSet = Arrays.asList((AnalyticItemWrapper<Long>) new LongCentroid(10, "", 0), (AnalyticItemWrapper<Long>) new LongCentroid(1000, "", 0));
    final double cost = fn.compute(dataSet, centroidSet, new AssociationNotification<Long>() {

        @Override
        public void notify(final CentroidPairing<Long> pairing) {
            Assert.assertTrue(expectedPairings.contains(pairing));
        }
    });
    Assert.assertEquals(expectedCost, cost, 0.0001);
}
Also used : LongCentroid(org.locationtech.geowave.analytic.clustering.LongCentroid) AnalyticItemWrapper(org.locationtech.geowave.analytic.AnalyticItemWrapper) Test(org.junit.Test)

Example 4 with LongCentroid

use of org.locationtech.geowave.analytic.clustering.LongCentroid in project geowave by locationtech.

the class StripWeakCentroidsRunnerTest method testMaxDense.

@Test
public void testMaxDense() throws Exception {
    final List<AnalyticItemWrapper<Long>> list = new ArrayList<>();
    final int[] cnts = new int[] { 900, 600, 800 };
    for (int i = 0; i < cnts.length; i++) {
        list.add(new LongCentroid(i, "", cnts[i]));
    }
    final TailMaxBreakStrategy<Long> breakS = new TailMaxBreakStrategy<>();
    assertEquals(3, breakS.getBreakPoint(list));
}
Also used : LongCentroid(org.locationtech.geowave.analytic.clustering.LongCentroid) TailMaxBreakStrategy(org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.TailMaxBreakStrategy) ArrayList(java.util.ArrayList) AnalyticItemWrapper(org.locationtech.geowave.analytic.AnalyticItemWrapper) Test(org.junit.Test)

Example 5 with LongCentroid

use of org.locationtech.geowave.analytic.clustering.LongCentroid in project geowave by locationtech.

the class StripWeakCentroidsRunnerTest method testStableUniform.

@Test
public void testStableUniform() throws Exception {
    final List<AnalyticItemWrapper<Long>> list = new ArrayList<>();
    final int[] cnts = new int[] { 1000, 851, 750, 650, 525, 200, 100, 90, 70 };
    for (int i = 0; i < cnts.length; i++) {
        list.add(new LongCentroid(i, "", cnts[i]));
    }
    final TailStableChangeBreakStrategy<Long> breakS = new TailStableChangeBreakStrategy<>();
    assertEquals(5, breakS.getBreakPoint(list));
}
Also used : LongCentroid(org.locationtech.geowave.analytic.clustering.LongCentroid) ArrayList(java.util.ArrayList) AnalyticItemWrapper(org.locationtech.geowave.analytic.AnalyticItemWrapper) TailStableChangeBreakStrategy(org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.TailStableChangeBreakStrategy) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)5 AnalyticItemWrapper (org.locationtech.geowave.analytic.AnalyticItemWrapper)5 LongCentroid (org.locationtech.geowave.analytic.clustering.LongCentroid)5 ArrayList (java.util.ArrayList)4 TailMaxBreakStrategy (org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.TailMaxBreakStrategy)2 TailStableChangeBreakStrategy (org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.TailStableChangeBreakStrategy)2 StableChangeBreakStrategy (org.locationtech.geowave.analytic.mapreduce.kmeans.runner.StripWeakCentroidsRunner.StableChangeBreakStrategy)1