def precision_recall_fscore(tp, fp, fn):
    """Return (precision, recall, f-score) for given counts."""
    prec = 0.0 if tp + fp == 0 else 1.*tp / (tp + fp)
    rec = 0.0 if tp + fn == 0 else 1.*tp / (tp + fn)
    f = 0.0 if prec + rec == 0.0 else 2 * prec * rec / (prec + rec)
    return prec, rec, f