voxseg_/evaluate.py
def print_confusion_matrix(scores: Dict[str,Dict[str,int]]) -> None:
    '''Prints the normalized confusion matrix.

    Args:
        scores: A dictionary of dictionaries containing TP, FP, FN and TN counts generated by score().
    '''

    tp, fp, fn, tn = 0, 0, 0, 0
    for i in scores:
        tp += scores[i]['TP']
        fp += scores[i]['FP']
        fn += scores[i]['FN']
        tn += scores[i]['TN']
    
    #logging.info('\t\t\t\tTrue\n' + \
    #      '\t\t\t\tSpeech\tNon-speech\n' + \
    #      'Predicted\tSpeech\t\t' + str(round(tp / (tp + fn + sys.float_info.epsilon), 3)) + '\t' + str(round(fp / (tn + fp + sys.float_info.epsilon), 3)) + '\n' + \
    #      '\t\tNon-speech\t'+ str(round(fn / (tp + fn + sys.float_info.epsilon), 3)) + '\t' + str(round(tn / (tn + fp + sys.float_info.epsilon), 3)))
       
    prec = tp / (tp + fp + sys.float_info.epsilon)
    rec = tp / (tp + fn + sys.float_info.epsilon)
    f1 = 2 * prec * rec / (prec + rec + sys.float_info.epsilon)
             
    logging.info("\nConfusion matrix VoxSeg (TP FP / FN TN):\n{}".format(pd.DataFrame([[tp, fp], [fn, tn]])))
    logging.info("Speech: {}, Non-speech: {}, All: {}".format(tp+fn, fp+tn, tp+fp+fn+tn))
    
    logging.info('Column scores VoxSeg:\tP = {}\tR = {}\tF1 = {}\tAcc = {}'.format(round(prec, 3), round(rec, 3), round(f1, 3), round((tp + tn)/(tp + fp + fn + tn + sys.float_info.epsilon), 3)))
Prints the normalized confusion matrix.

    Args:
        scores: A dictionary of dictionaries containing TP, FP, FN and TN counts generated by score().
    
Prints the normalized confusion matrix.
Prints the normalized confusion matrix .
def print_confusion_matrix(scores: Dict[str,Dict[str,int]]) -> None:
    tp, fp, fn, tn = 0, 0, 0, 0
    for i in scores:
        tp += scores[i]['TP']
        fp += scores[i]['FP']
        fn += scores[i]['FN']
        tn += scores[i]['TN']
    prec = tp / (tp + fp + sys.float_info.epsilon)
    rec = tp / (tp + fn + sys.float_info.epsilon)
    f1 = 2 * prec * rec / (prec + rec + sys.float_info.epsilon)
    logging.info("\nConfusion matrix VoxSeg (TP FP / FN TN):\n{}".format(pd.DataFrame([[tp, fp], [fn, tn]])))
    logging.info("Speech: {}, Non-speech: {}, All: {}".format(tp+fn, fp+tn, tp+fp+fn+tn))
    logging.info('Column scores VoxSeg:\tP = {}\tR = {}\tF1 = {}\tAcc = {}'.format(round(prec, 3), round(rec, 3), round(f1, 3), round((tp + tn)/(tp + fp + fn + tn + sys.float_info.epsilon), 3)))
def print_confusion_matrix ( scores : Dict [ str , Dict [ str , int ] ] ) -> None : tp , fp , fn , tn = 0 , 0 , 0 , 0 for i in scores : tp += scores [ i ] [ 'TP' ] fp += scores [ i ] [ 'FP' ] fn += scores [ i ] [ 'FN' ] tn += scores [ i ] [ 'TN' ] prec = tp / ( tp + fp + sys . float_info . epsilon ) rec = tp / ( tp + fn + sys . float_info . epsilon ) f1 = 2 * prec * rec / ( prec + rec + sys . float_info . epsilon ) logging . info ( "\nConfusion matrix VoxSeg (TP FP / FN TN):\n{}" . format ( pd . DataFrame ( [ [ tp , fp ] , [ fn , tn ] ] ) ) ) logging . info ( "Speech: {}, Non-speech: {}, All: {}" . format ( tp + fn , fp + tn , tp + fp + fn + tn ) ) logging . info ( 'Column scores VoxSeg:\tP = {}\tR = {}\tF1 = {}\tAcc = {}' . format ( round ( prec , 3 ) , round ( rec , 3 ) , round ( f1 , 3 ) , round ( ( tp + tn ) / ( tp + fp + fn + tn + sys . float_info . epsilon ) , 3 ) ) )
Prints the normalized confusion matrix.
Prints the normalized confusion matrix .
'''Prints the normalized confusion matrix.

    Args:
        scores: A dictionary of dictionaries containing TP, FP, FN and TN counts generated by score().
    ''' #logging.info('\t\t\t\tTrue\n' + \ #      '\t\t\t\tSpeech\tNon-speech\n' + \ #      'Predicted\tSpeech\t\t' + str(round(tp / (tp + fn + sys.float_info.epsilon), 3)) + '\t' + str(round(fp / (tn + fp + sys.float_info.epsilon), 3)) + '\n' + \ #      '\t\tNon-speech\t'+ str(round(fn / (tp + fn + sys.float_info.epsilon), 3)) + '\t' + str(round(tn / (tn + fp + sys.float_info.epsilon), 3)))
scores
Dict[str,Dict[str,int]]
A dictionary of dictionaries containing TP, FP, FN and TN counts generated by score().
A dictionary of dictionaries containing TP FP FN and TN counts generated by score () .