@staticmethod
def precision(y, y_pred):
    """compute precision"""
    TP = (y[y == 1] == y_pred[y == 1]).sum()
    FP = (y[y == 0] != y_pred[y == 0]).sum()
    if TP + FP == 0:
        return 0
    return TP / float(TP + FP)
