def test_precision_recall_and_f_calculation(self): ede = ClusteringEvaluator() targets = [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1 , 1, 2, 2, 2, 2, 2, 2] predictions = [0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1 , 2, 2, 2, 2, 2, 0, 2] confusion_matrix = ede.create_confusion_matrix(targets, predictions, 3) rp_rates = ede.calculate_precision_recall(confusion_matrix) fs = ede.calculate_f_measure(rp_rates) self.assertEquals(sum(fs), [2.5])