@Test public void testGaussianClusterClassification() { ClusterClassifier classifier = newGaussianClassifier(); Vector pdf = classifier.classify(new DenseVector(2)); assertEquals("[0,0]", "[0.212, 0.576, 0.212]", AbstractCluster.formatVector(pdf, null)); pdf = classifier.classify(new DenseVector(2).assign(2)); assertEquals("[2,2]", "[0.952, 0.047, 0.000]", AbstractCluster.formatVector(pdf, null)); }
@Test public void testSoftClusterClassification() { ClusterClassifier classifier = newSoftClusterClassifier(); Vector pdf = classifier.classify(new DenseVector(2)); assertEquals("[0,0]", "[0.000, 1.000, 0.000]", AbstractCluster.formatVector(pdf, null)); pdf = classifier.classify(new DenseVector(2).assign(2)); assertEquals("[2,2]", "[0.735, 0.184, 0.082]", AbstractCluster.formatVector(pdf, null)); }
@Test public void testClusterClassification() { ClusterClassifier classifier = newClusterClassifier(); Vector pdf = classifier.classify(new DenseVector(2)); assertEquals("[0,0]", "[0.107, 0.787, 0.107]", AbstractCluster.formatVector(pdf, null)); pdf = classifier.classify(new DenseVector(2).assign(2)); assertEquals("[2,2]", "[0.867, 0.117, 0.016]", AbstractCluster.formatVector(pdf, null)); }
@Test public void testCanopyClassification() { List<Cluster> models = Lists.newArrayList(); DistanceMeasure measure = new ManhattanDistanceMeasure(); models.add(new Canopy(new DenseVector(2).assign(1), 0, measure)); models.add(new Canopy(new DenseVector(2), 1, measure)); models.add(new Canopy(new DenseVector(2).assign(-1), 2, measure)); ClusterClassifier classifier = new ClusterClassifier(models); Vector pdf = classifier.classify(new DenseVector(2)); assertEquals("[0,0]", "[0.107, 0.787, 0.107]", AbstractCluster.formatVector(pdf, null)); pdf = classifier.classify(new DenseVector(2).assign(2)); assertEquals("[2,2]", "[0.867, 0.117, 0.016]", AbstractCluster.formatVector(pdf, null)); }
@Test(expected = UnsupportedOperationException.class) public void testMSCanopyClassification() { List<Cluster> models = Lists.newArrayList(); DistanceMeasure measure = new ManhattanDistanceMeasure(); models.add(new MeanShiftCanopy(new DenseVector(2).assign(1), 0, measure)); models.add(new MeanShiftCanopy(new DenseVector(2), 1, measure)); models.add(new MeanShiftCanopy(new DenseVector(2).assign(-1), 2, measure)); ClusterClassifier classifier = new ClusterClassifier(models); classifier.classify(new DenseVector(2)); }