def compute_precision(confusionMatrix): 
    """
    Compute precision based on a Confusion Matrix 
    with prediction on rows 
    and truth on columns.
    precision = true positive / (true positive + false positive)
    """    
    precision = []
    for i in range(confusionMatrix.shape[0]):
        tot = 0
        for j in range(confusionMatrix.shape[0]):
            tot += confusionMatrix[i, j]  
        correct = confusionMatrix[i, i] 
        precision.append(correct/tot)
    return precision