def test_evaluate_preset(self, ground_truth, predictions, expected_recall): tensor_shape = random_tensor_shape() ground_truth_labels = np.tile(ground_truth, tensor_shape + [1]) predicted_labels = np.tile(predictions, tensor_shape + [1]) expected = np.tile(expected_recall, tensor_shape) result = recall.evaluate(ground_truth_labels, predicted_labels, classes=[1]) self.assertAllClose(expected, result)
def test_evaluate_preset_multiclass(self, ground_truth, predictions, classes, reduce_average, expected_recall): tensor_shape = random_tensor_shape() ground_truth_labels = np.tile(ground_truth, tensor_shape + [1]) predicted_labels = np.tile(predictions, tensor_shape + [1]) expected = np.tile(expected_recall, tensor_shape + ([1] if not reduce_average else [])) result = recall.evaluate(ground_truth_labels, predicted_labels, classes, reduce_average) self.assertAllClose(expected, result)
def binary_recall_function(ground_truth, predictions): return recall.evaluate(ground_truth, predictions, classes=[1])