Skip to content

Commit fa1ee26

Browse files
authored
Set _DEFAULT_NUM_THRESHOLDS to 201 (#645)
Set the default number of thresholds used by PR curve summary calculations to 201 instead of 200. 200 yielded strange, unfriendly bin edges. The number of bins is 1 less than the number of thresholds. Hence, it usually makes more sense for the number of thresholds to be odd. This is a request from Waymo folks.
1 parent 18b7e41 commit fa1ee26

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Diff for: tensorboard/plugins/pr_curve/summary.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
_MINIMUM_COUNT = 1.0
3333

3434
# The default number of thresholds.
35-
_DEFAULT_NUM_THRESHOLDS = 200
35+
_DEFAULT_NUM_THRESHOLDS = 201
3636

3737
def op(
3838
name,
@@ -185,7 +185,7 @@ def pb(name,
185185
Dimensions must match those of `labels`.
186186
num_thresholds: Optional number of thresholds, evenly distributed in
187187
`[0, 1]`, to compute PR metrics for. When provided, should be an int of
188-
value at least 2. Defaults to 200.
188+
value at least 2. Defaults to 201.
189189
weights: Optional float or float32 numpy array. Individual counts are
190190
multiplied by this value. This tensor must be either the same shape as
191191
or broadcastable to the `labels` numpy array.
@@ -240,7 +240,7 @@ def pb(name,
240240
def streaming_op(name,
241241
labels,
242242
predictions,
243-
num_thresholds=200,
243+
num_thresholds=None,
244244
weights=None,
245245
metrics_collections=None,
246246
updates_collections=None,
@@ -264,7 +264,7 @@ def streaming_op(name,
264264
predictions: A floating point `Tensor` of arbitrary shape and whose values
265265
are in the range `[0, 1]`.
266266
num_thresholds: The number of evenly spaced thresholds to generate for
267-
computing the PR curve.
267+
computing the PR curve. Defaults to 201.
268268
weights: Optional `Tensor` whose rank is either 0, or the same rank as
269269
`labels`, and must be broadcastable to `labels` (i.e., all dimensions must
270270
be either `1`, or the same as the corresponding `labels` dimension).
@@ -285,6 +285,9 @@ def streaming_op(name,
285285
positives, true negatives, false negatives, precision, recall.
286286
update_op: An operation that updates the summary with the latest data.
287287
"""
288+
if num_thresholds is None:
289+
num_thresholds = _DEFAULT_NUM_THRESHOLDS
290+
288291
thresholds = [i / float(num_thresholds - 1)
289292
for i in range(num_thresholds)]
290293

0 commit comments

Comments
 (0)