(pred_matrix, label_matrix)
return precision, recall, overall_prec, overall_recall
Helper method that calculates confusion matrix.
Helper method that calculates confusion matrix.
Helper method that calculates confusion matrix .
def calculate_confusion_multi(pred_matrix, label_matrix):
    """Helper method that calculates confusion matrix."""
    tp = np.sum(np.logical_and(pred_matrix, label_matrix), axis=0)
    tp_fp = np.sum(pred_matrix, axis=0)
    tp_fn = np.sum(label_matrix, axis=0)
    precision = tp.astype(np.float32)/(tp_fp+1e-40)
    recall = tp.astype(np.float32)/(tp_fn+1e-40)
    overall_prec = np.float(np.sum(tp))/(np.sum(tp_fp)+1e-40)
    overall_recall = np.float(np.sum(tp))/(np.sum(tp_fn)+1e-40)
    return precision, recall, overall_prec, overall_recall
def calculate_confusion_multi ( pred_matrix , label_matrix ) : tp = np . sum ( np . logical_and ( pred_matrix , label_matrix ) , axis = 0 ) tp_fp = np . sum ( pred_matrix , axis = 0 ) tp_fn = np . sum ( label_matrix , axis = 0 ) precision = tp . astype ( np . float32 ) / ( tp_fp + 1e-40 ) recall = tp . astype ( np . float32 ) / ( tp_fn + 1e-40 ) overall_prec = np . float ( np . sum ( tp ) ) / ( np . sum ( tp_fp ) + 1e-40 ) overall_recall = np . float ( np . sum ( tp ) ) / ( np . sum ( tp_fn ) + 1e-40 ) return precision , recall , overall_prec , overall_recall