def _compute_curve(labels, predictions, num_thresholds, weights=None):
if weights is None:<EOL><INDENT>weights = <NUM_LIT:1.0><EOL><DEDENT>bucket_indices = np.int32(np.floor(predictions * (num_thresholds - <NUM_LIT:1>)))<EOL>float_labels = labels.astype(np.float)<EOL>histogram_range = (<NUM_LIT:0>, num_thresholds - <NUM_LIT:1>)<EOL>tp_buckets, _ = np.histogram(<EOL>bucket_indices,<EOL>bins=num_thresholds,<EOL>range=histogram_range,<EOL>weights=float_labels * weights)<EOL>fp_buckets, _ = np.histogram(<EOL>bucket_indices,<EOL>bins=num_thresholds,<EOL>range=histogram_range,<EOL>weights=(<NUM_LIT:1.0> - float_labels) * weights)<EOL>tp = np.cumsum(tp_buckets[::-<NUM_LIT:1>])[::-<NUM_LIT:1>]<EOL>fp = np.cumsum(fp_buckets[::-<NUM_LIT:1>])[::-<NUM_LIT:1>]<EOL>tn = fp[<NUM_LIT:0>] - fp<EOL>fn = tp[<NUM_LIT:0>] - tp<EOL>precision = tp / np.maximum(_MINIMUM_COUNT, tp + fp)<EOL>recall = tp / np.maximum(_MINIMUM_COUNT, tp + fn)<EOL>return np.stack((tp, fp, tn, fn, precision, recall))<EOL>
This function is another implementation of functions in
    https://github.com/tensorflow/tensorboard/blob/master/tensorboard/plugins/pr_curve/summary.py