MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / result

Method result

tensorflow/python/keras/metrics.py:1819–1852  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1817 name='interpolate_pr_auc')
1818
1819 def result(self):
1820 if (self.curve == metrics_utils.AUCCurve.PR and
1821 self.summation_method == metrics_utils.AUCSummationMethod.INTERPOLATION
1822 ):
1823 # This use case is different and is handled separately.
1824 return self.interpolate_pr_auc()
1825
1826 # Set `x` and `y` values for the curves based on `curve` config.
1827 recall = math_ops.div_no_nan(self.true_positives,
1828 self.true_positives + self.false_negatives)
1829 if self.curve == metrics_utils.AUCCurve.ROC:
1830 fp_rate = math_ops.div_no_nan(self.false_positives,
1831 self.false_positives + self.true_negatives)
1832 x = fp_rate
1833 y = recall
1834 else: # curve == 'PR'.
1835 precision = math_ops.div_no_nan(
1836 self.true_positives, self.true_positives + self.false_positives)
1837 x = recall
1838 y = precision
1839
1840 # Find the rectangle heights based on `summation_method`.
1841 if self.summation_method == metrics_utils.AUCSummationMethod.INTERPOLATION:
1842 # Note: the case ('PR', 'interpolation') has been handled above.
1843 heights = (y[:self.num_thresholds - 1] + y[1:]) / 2.
1844 elif self.summation_method == metrics_utils.AUCSummationMethod.MINORING:
1845 heights = math_ops.minimum(y[:self.num_thresholds - 1], y[1:])
1846 else: # self.summation_method = metrics_utils.AUCSummationMethod.MAJORING:
1847 heights = math_ops.maximum(y[:self.num_thresholds - 1], y[1:])
1848
1849 # Sum up the areas of all the rectangles.
1850 return math_ops.reduce_sum(
1851 math_ops.multiply(x[:self.num_thresholds - 1] - x[1:], heights),
1852 name=self.name)
1853
1854 def reset_states(self):
1855 K.batch_set_value(

Callers 15

__getitem__Method · 0.45
__getitem__Method · 0.45
iteration_inside_funcFunction · 0.45
iteration_outside_funcFunction · 0.45
_test_metricMethod · 0.45
train_stepFunction · 0.45
test_unweightedMethod · 0.45

Calls 5

interpolate_pr_aucMethod · 0.95
minimumMethod · 0.80
maximumMethod · 0.80
reduce_sumMethod · 0.80
multiplyMethod · 0.80

Tested by 15

iteration_inside_funcFunction · 0.36
iteration_outside_funcFunction · 0.36
_test_metricMethod · 0.36
train_stepFunction · 0.36
test_unweightedMethod · 0.36
test_unweightedMethod · 0.36
test_unweightedMethod · 0.36