def test_createCluster2_onlyOneOutlier_2D(self): d = 2 classA = SampleContainer([(0.0, 0.0), (0.0, 1.0), (0.0, 2.0), (0.0, 3.0)], d) classB = SampleContainer([(0.0, 1.5)], d) clusters = createClusters(classA, classB) for spl in classA.getSamples(): self.assertTrue(spl in clusters.getSamples().getSamples())
def test_createClusters2_onlyOneSampleForCluster_2D(self): d = 2 s0_1, s0_2, s0_3, s0_4 = (0.0, 2.0), (0.0, 4.0), (0.0, 6.0), (0.0, 8.0) s1_1, s1_2, s1_3, s1_4 = (0.0, 1.0), (0.0, 3.0), (0.0, 5.0), (0.0, 7.0) classA = SampleContainer([s1_1, s1_2, s1_3, s1_4], d) classB = SampleContainer([s0_1, s0_2, s0_3, s0_4], d) clusters = createClusters(classA, classB) for spl in classA.getSamples(): self.assertTrue(spl in clusters.getSamples().getSamples())
def test_DefineClusterNoneOutlierOnlyOneSample_4D(self): d = 4 sA = Sample((0.0, 0.0, 0.0, 0.0)) classA = SampleContainer([sA], d) classB = SampleContainer([(0.0, 4.0, 0.0, 0.0)], d) clusters = createClusters(classA, classB) self.assertEquals(clusters.getSize(), 1, "solo debe generarce un cluster") self.assertTrue(sA in clusters.getClusters().pop().getSamples())
def test_onlyOneOutlier_3D(self): d = 3 classA = SampleContainer([(0.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 2.0, 0.0), (0.0, 3.0, 0.0)], d) classB = SampleContainer([(0.0, 1.5, 0.0)], d) clusters = createClusters(classA, classB) clusters_test = ClusterContainer([ Cluster([(0.0, 2.0, 0.0), (0.0, 3.0, 0.0)], d), Cluster([(0.0, 0.0, 0.0), (0.0, 1.0, 0.0)], d) ], d) self.assertEquals( clusters, clusters_test, "las muestras mergeables deben estar en el mismo cluster")
def test_createClusters2_severalOutliers2D(self): d = 2 s1, s2, s3, s4, s5 = (3.0, 7.0), (3.0, 6.0), (10.0, 7.0), (10.0, 6.0), (6.5, 6.5) samplesA = SampleContainer([s1, s2, s3, s4, s5], d) samplesB = SampleContainer([(6.0, 7.0), (6.0, 6.0), (7.0, 6.0), (7.0, 7.0), (6.0, 6.5), (7.0, 6.5)], d) c1 = Cluster([s1, s2], d) c2 = Cluster([s4, s3], d) c3 = Cluster([s5], d) clusters = createClusters(samplesA, samplesB) for spl in samplesA.getSamples(): self.assertTrue(spl in clusters.getSamples().getSamples())
def test_onlyOneSampleForCluster_2D(self): d = 2 s0_1, s0_2, s0_3, s0_4 = (0.0, 2.0), (0.0, 4.0), (0.0, 6.0), (0.0, 8.0) s1_1, s1_2, s1_3, s1_4 = (0.0, 1.0), (0.0, 3.0), (0.0, 5.0), (0.0, 7.0) classA = SampleContainer([s1_1, s1_2, s1_3, s1_4], d) classB = SampleContainer([s0_1, s0_2, s0_3, s0_4], d) clusters = createClusters(classA, classB) clusters_test = ClusterContainer([ Cluster([s1_1], d), Cluster([s1_2], d), Cluster([s1_3], d), Cluster([s1_4], d) ], d) self.assertEquals(clusters, clusters_test, "debe generarce un cluster para cada muestra")
def test_createClusters_allSamplesInTheSameCluster_2D(self): d = 2 s0_1, s0_2, s0_3 = Sample((3.0, 3.0)), Sample((4.0, 4.0)), Sample( (3.0, 4.0)) s1_1, s1_2, s1_3, s1_4, s1_5, s1_6 = Sample((0.0, 1.0)), Sample( (0.0, 2.0)), Sample((0.0, 3.0)), Sample((1.0, 0.0)), Sample( (1.0, 1.0)), Sample((1.0, 2.0)) class0 = SampleContainer([s0_1, s0_2, s0_3], d) class1 = SampleContainer([s1_1, s1_2, s1_3, s1_4, s1_5, s1_6], d) clusters_test = ClusterContainer( [Cluster([s1_1, s1_2, s1_3, s1_4, s1_5, s1_6], d)], d) clusters = createClusters(class1, class0) self.assertEquals( clusters_test, clusters, "todas las muestras deben estar en un unico cluster")
def test_createClusters_severalOutliers2D(self): d = 2 s1, s2, s3, s4, s5 = (3.0, 7.0), (3.0, 6.0), (10.0, 7.0), (10.0, 6.0), (6.5, 6.5) samplesA = SampleContainer([s1, s2, s3, s4, s5], d) samplesB = SampleContainer([(6.0, 7.0), (6.0, 6.0), (7.0, 6.0), (7.0, 7.0), (6.0, 6.5), (7.0, 6.5)], d) c1 = Cluster([s1, s2], d) c2 = Cluster([s4, s3], d) c3 = Cluster([s5], d) container_test = ClusterContainer([c1, c2, c3], d) container = createClusters(samplesA, samplesB) self.assertEquals( container, container_test, "Deben definirse los clusters: [s1,s2],[s3,s4],[s5]")