def balanced_accuracy(sensitivity, specificity, factor=0.5):
    """Balanced accuracy

    Wikipedia entry https://en.wikipedia.org/wiki/Accuracy_and_precision

    Parameters
    ----------
    sensitivity : float in [0, 1]
        sensitivity.

    specificity : float in [0, 1]
        specificity.

    factor : float in [0, 1]
        Balancing factor multiplying true positive rate (sensitivity).
        Default value 0.5

    Returns
    -------
    bacc: float
        Balanced accuracy

    """

    return float(((1-factor) * sensitivity) + (factor * specificity))