예제 #1
0
  def test_evaluate_preset(self, ground_truth, predictions, expected_precision):
    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_precision, tensor_shape)

    result = precision.evaluate(
        ground_truth_labels, predicted_labels, classes=[1])

    self.assertAllClose(expected, result)
예제 #2
0
  def test_evaluate_preset_multiclass(self, ground_truth, predictions, classes,
                                      reduce_average, expected_precision):
    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_precision,
                       tensor_shape + ([1] if not reduce_average else []))

    result = precision.evaluate(ground_truth_labels, predicted_labels, classes,
                                reduce_average)

    self.assertAllClose(expected, result)
예제 #3
0
def binary_precision_function(ground_truth, predictions):
    return precision.evaluate(ground_truth, predictions, classes=[1])