コード例 #1
0
ファイル: test_tree.py プロジェクト: barblin/clus-wasser
    def test_same_amount_of_neighbours(self):
        features = load_file_features("skinnyDipData_0.csv")
        tree = create_tree(features)

        for edge in tree.edges:
            self.assertEqual(200, len(tree.neighbours[edge.src]), "All vertices should have same amount of neighbours")
            self.assertEqual(200, len(tree.neighbours[edge.dest]), "All vertices should have same amount of neighbours")
コード例 #2
0
ファイル: test_tree.py プロジェクト: barblin/clus-wasser
    def test_sorted_by_eucledian_cost(self):
        features = load_file_features("skinnyDipData_0.csv")
        tree = create_tree(features)
        tree.sort()

        last = 0
        for edge in tree.edges:
            self.assertTrue(last <= edge.cost, "Tree is supposed to be sorted by wasser cost")
            last = edge.cost
コード例 #3
0
ファイル: test_tree.py プロジェクト: barblin/clus-wasser
    def test_create_tree(self):
        features = load_file_features("skinnyDipData_0.csv")
        tree = create_tree(features)
        tree.wasser_cost_calc()

        self.assertEqual(3000, tree.number_vertices, "Tree is supposed to have all data points")
        self.assertEqual(17949, len(tree.edges), "Tree is supposed to contain all edges")
        self.assertEqual(0, tree.min_wasser, "Min wasser is supposed to be updated")
        self.assertEqual(0.43006119008417043, tree.max_wasser, "Max wasser is supposed to be updated")
コード例 #4
0
    def test_cluster_with_margin(self):
        features = load_file_features("skinnyDipData_0.csv")
        labels = load_file_labels("skinnyDipData_0.csv")

        increment = wasser(features, 0.018500000000000003, labels, 5)
        clusters = increment.clusters
        cluster = clusters[1941]
        noise_cluster = clusters[-1]
        self.assertEqual(382, cluster.sz, "Cluster size should be of correct size")
        self.assertEqual(2618, noise_cluster.sz, "Noise cluster should be of correct size")

        total_sz = 0

        for key in clusters.keys():
            total_sz += clusters[key].sz

        self.assertEqual(3000, total_sz, "The total amount of vertices should remain 3000")
コード例 #5
0
    def test_cluster_range_with_labels(self):
        features = load_file_features("skinnyDipData_0.csv")
        labels = load_file_labels("skinnyDipData_0.csv")
        increments = wasser_range(features, 0.0185, 0.02, 0.0003, labels, 5)

        self.assertEqual(6, len(increments), "Wasser_range should produce expected amounts of increments")

        clusters = increments[-1].clusters
        cluster = clusters[1941]

        noise_cluster = clusters[-1]
        self.assertEqual(414, cluster.sz, "Cluster size should be of correct size")
        self.assertEqual(2586, noise_cluster.sz, "Noise cluster should be of correct size")

        total_sz = 0

        for key in clusters.keys():
            total_sz += clusters[key].sz

        self.assertEqual(3000, total_sz, "The total amount of vertices should remain 3000")