def compute_specificity(cm):
    """
    Computes specificity for binary classification problems
    :param cm: A Numpy-like matrix that represents a confusion matrix
    :return: The specificity of the confusion matrix
    """
    print(cm.shape)
    print(len(cm.shape))
    assert len(cm.shape) and cm.shape[0] == cm.shape[1] and cm.shape[0] == 2
    TP = cm[1, 1]
    TN = cm[0, 0]
    FN = cm[1, 0]
    FP = cm[0, 1]
    if FP+TN == 0:
        return 0
    return float(TN)/(FP + TN)