示例#1
0
 def test_get_maximum_for_dataset2(self):
     keywords_dont_matter_here = ['']
     kwc1 = KeywordCoordinate(0, 0, keywords_dont_matter_here)
     kwc2 = KeywordCoordinate(1, 1, keywords_dont_matter_here)
     kwc3 = KeywordCoordinate(2, 2, keywords_dont_matter_here)
     kwc4 = KeywordCoordinate(3, 3, keywords_dont_matter_here)
     kwc5 = KeywordCoordinate(4, 4, keywords_dont_matter_here)
     kwc6 = KeywordCoordinate(5, 5, keywords_dont_matter_here)
     dataset: dataset_type = [kwc1, kwc2, kwc3, kwc4, kwc5, kwc6]
     cf = CostFunction(manhattan_distance, separated_cosine_similarity, 0.3,
                       0.3, 0.4)
     result = cf.get_maximum_for_dataset(dataset)
     self.assertAlmostEqual(result, 10.0, delta=0.01)
示例#2
0
 def test_get_maximum_for_dataset4(self):
     keywords_dont_matter_here = ['']
     kwc1 = KeywordCoordinate(6, 6, keywords_dont_matter_here)
     kwc2 = KeywordCoordinate(8, 8, keywords_dont_matter_here)
     kwc3 = KeywordCoordinate(9, 9, keywords_dont_matter_here)
     kwc4 = KeywordCoordinate(13, 13, keywords_dont_matter_here)
     kwc5 = KeywordCoordinate(24, 24, keywords_dont_matter_here)
     kwc6 = KeywordCoordinate(35, 35, keywords_dont_matter_here)
     dataset: dataset_type = [kwc1, kwc2, kwc3, kwc4, kwc5, kwc6]
     cf = CostFunction(manhattan_distance, separated_cosine_similarity, 0.3,
                       0.3, 0.4)
     result = cf.get_maximum_for_dataset(dataset)
     self.assertAlmostEqual(result, 58.0, delta=0.01)
示例#3
0
def get_max_inter_dataset_distances(costfunction: CostFunction, subsets):
    """
    This function gets executed inside every maximum inter-dataset distance process.
    :param costfunction: The CostFunction
    :param subsets: The subsets for the process
    :return: A list with tuples of the costs and their corresponding subset
    """
    results = []
    # count = 1
    for subset in subsets:
        # print('Subset: ', count)
        # count = count + 1
        # print('*** ', subset)
        current_cost = costfunction.get_maximum_for_dataset(subset)
        results.append((current_cost, subset))
    return results