def contingency_table(ys, yhats, positive=True):
    """Computes a contingency table for given predictions.

    :param ys: true labels
    :type ys: iterable
    :param yhats: predicted labels
    :type yhats: iterable
    :param positive: the positive label

    :return: TP, FP, TN, FN

    >>> ys =    [True, True, True, True, True, False]
    >>> yhats = [True, True, False, False, False, True]
    >>> tab = contingency_table(ys, yhats, 1)
    >>> print(tab)
    (2, 1, 0, 3)

    """
    TP = 0
    TN = 0
    FP = 0
    FN = 0
    for y, yhat in zip(ys, yhats):
        if y == positive:
            if y == yhat:
                TP += 1
            else:
                FN += 1
        else:
            if y == yhat:
                TN += 1
            else:
                FP += 1
    return TP, FP, TN, FN