def aprf(g):
  """Returns precision, recall and F of the given statistics."""
  tp, _, sys_pos, real_pos = sum([x[-1] for x in g])
  if tp == 0:
    p = r = f = 0.0
  else:
    p = tp / float(sys_pos) if sys_pos > 0 else 0.
    r = tp / float(real_pos) if real_pos > 0 else 0.
    f = 2 * p * r / (p + r)
  return np.asarray([p, r, f])
Returns precision, recall and F of the given statistics.
language/labs/drkit/evaluate.py