(target_y, predict_y)
return label_dict
compute TP, FP, FN given target lable and predict label
    :param target_y:
    :param predict_y:
    :param label_dict {label:(TP,FP,FN)}
    :return: macro_f1(a scalar),micro_f1(a scalar)
compute TP, FP, FN given target lable and predict label
    :param target_y:
    :param predict_y:
    :param label_dict {label:(TP,FP,FN)}
    :return: macro_f1(a scalar),micro_f1(a scalar)
compute TP FP FN given target lable and predict label : param target_y : : param predict_y : : param label_dict { label : ( TP FP FN ) } : return : macro_f1 ( a scalar ) micro_f1 ( a scalar )
def compute_confuse_matrix(target_y, predict_y):
    """
    compute TP, FP, FN given target lable and predict label
    :param target_y:
    :param predict_y:
    :param label_dict {label:(TP,FP,FN)}
    :return: macro_f1(a scalar),micro_f1(a scalar)
    """
    # count number of TP,FP,FN for each class

    label_dict = {}
    for i in range(len(cat_to_id)):
        label_dict[i] = (0, 0, 0)

    for num in range(len(target_y)):
        targe_tmp = target_y[num]
        pre_tmp = predict_y[num]
        unique_labels = set(targe_tmp + pre_tmp)
        for label in unique_labels:
            TP, FP, FN = label_dict[label]
            if label in pre_tmp and label in targe_tmp:  # predict=1,truth=1 (TP)
                TP = TP + 1
            elif label in pre_tmp and label not in targe_tmp:  # predict=1,truth=0(FP)
                FP = FP + 1
            elif label not in pre_tmp and label in targe_tmp:  # predict=0,truth=1(FN)
                FN = FN + 1
            label_dict[label] = (TP, FP, FN)
    return label_dict
def compute_confuse_matrix ( target_y , predict_y ) : # count number of TP,FP,FN for each class label_dict = { } for i in range ( len ( cat_to_id ) ) : label_dict [ i ] = ( 0 , 0 , 0 ) for num in range ( len ( target_y ) ) : targe_tmp = target_y [ num ] pre_tmp = predict_y [ num ] unique_labels = set ( targe_tmp + pre_tmp ) for label in unique_labels : TP , FP , FN = label_dict [ label ] if label in pre_tmp and label in targe_tmp : # predict=1,truth=1 (TP) TP = TP + 1 elif label in pre_tmp and label not in targe_tmp : # predict=1,truth=0(FP) FP = FP + 1 elif label not in pre_tmp and label in targe_tmp : # predict=0,truth=1(FN) FN = FN + 1 label_dict [ label ] = ( TP , FP , FN ) return label_dict