def rr(y_true):
  """Return the reciprical rank of the first positive candidate."""
  for index in range(0, len(y_true)):
    if y_true[index]:
      return 1.0 / (index + 1)
  return 0.0
Return the reciprical rank of the first positive candidate.
language/multivec/models/metrics.py