コード例 #1
0
ファイル: TestKmedoids.py プロジェクト: ztypaker/pyProCT
    def test_gromos_seeding(self):
        points = [(0, 0), (0, 1), (0, -1), (1, 0), (3, 0), (3, 1), (6, 0),
                  (7, 0), (7, 1), (7, -1)]
        #          Maximum distance of connected components is 1, for 1.5 it may discover 3 clusters.
        #          For 3.2 it may discover only 2
        #
        #         1       5         8
        #         |       |         |
        #         0 - 3   4     6 - 7
        #         |                 |
        #         2                 9
        #

        matrix = CondensedMatrix(pdist(points))
        kmed_alg = KMedoidsAlgorithm(matrix, rand_seed=10)

        # With a small cutoff we get all 3 connected components
        numpy.testing.assert_array_equal(
            kmed_alg.gromos_seeding(3, 1.4), [0, 7, 4]
        )  # if it's 1.5 we'll have 6 instead of 7 as medoid (as it is the first one to have 3 neighbours)

        # With a bigger cutoff it has to try to find the minimum cutoff for 3 clusters, then 6 is returned instead of 7
        numpy.testing.assert_array_equal(kmed_alg.gromos_seeding(3, 3.2),
                                         [3, 6, 5])

        # This one is regression
        numpy.testing.assert_array_equal(kmed_alg.gromos_seeding(2, 3.2),
                                         [4, 7])

        # This one should return a random sequence, so is only testable because of the rand_seed
        numpy.testing.assert_array_equal(kmed_alg.gromos_seeding(2, 0), [5, 3])
コード例 #2
0
ファイル: TestKmedoids.py プロジェクト: migonsu/pyProCT
    def test_gromos_seeding(self):
        points = [(0,0),(0,1),(0,-1),(1,0),
                  (3,0),(3,1),
                  (6,0),(7,0),(7,1),(7,-1)]
#          Maximum distance of connected components is 1, for 1.5 it may discover 3 clusters.
#          For 3.2 it may discover only 2
#
#         1       5         8
#         |       |         |
#         0 - 3   4     6 - 7 
#         |                 |
#         2                 9
#         
         
        matrix = CondensedMatrix(pdist(points))
        kmed_alg = KMedoidsAlgorithm(matrix, rand_seed = 10)
         
        # With a small cutoff we get all 3 connected components
        numpy.testing.assert_array_equal( kmed_alg.gromos_seeding(3, 1.4),[0, 7, 4]) # if it's 1.5 we'll have 6 instead of 7 as medoid (as it is the first one to have 3 neighbours)
         
        # With a bigger cutoff it has to try to find the minimum cutoff for 3 clusters, then 6 is returned instead of 7
        numpy.testing.assert_array_equal( kmed_alg.gromos_seeding(3, 3.2),[3, 6, 5])
         
        # This one is regression
        numpy.testing.assert_array_equal( kmed_alg.gromos_seeding(2, 3.2),[4, 7])
         
        # This one should return a random sequence, so is only testable because of the rand_seed
        numpy.testing.assert_array_equal(kmed_alg.gromos_seeding(2, 0), [5, 3])