def measure_performance(actual, prediction, verbose=False):
    """
    Return a performance breakdown in the form FAR, FRR and TPR

    Args:
        actual: correct (a priori) predictions
        prediction: predictions of a model

    Returns:
        res: List<FAR:float, FRR:float, TPR:float>

    """
    tp = 0
    fp = 0
    tn = 0
    fn = 0

    assert len(actual) == len(prediction), "Array lengths do not match"

    for i in range(len(actual)):
        if actual[i] == 1:
            if prediction[i] == 1:
                tp += 1
            else:
                fn += 1
        elif actual[i] == 0:
            if prediction[i] == 0:
                tn += 1
            if prediction[i] == 1:
                fp += 1

    assert tp + fp + tn + fn == len(actual), "Class labels should be binary (1 or 0)"
    if verbose:
        return [tp,fp, tn, fn]

    res = [fp / (fp + tn) if (fp + tn) != 0 else 0,  # FAR
           fn / (tp + fn) if (tp + fn) != 0 else 0,  # FRR
           (tp + tn) / (tp + tn + fp + fn) if (tp + tn + fp + fn) != 0 else 0,  # TPR
           ]

    return res