voxseg_/evaluate.py
def score(wav_scp: pd.DataFrame, sys_segs: pd.DataFrame, ref_segs: pd.DataFrame, wav_segs: pd.DataFrame, winlen: float) -> Dict[str,Dict[str,int]]:
    '''Function for calculating the TP, FP, FN and TN counts from VAD segments and ground truth reference segments.

    Args:
        wav_scp: A pd.DataFrame containing information about the wavefiles that have been segmented.
        sys_segs: A pd.DataFrame containing the endpoints produced by a VAD system.
        ref_segs: A pd.DataFrame containing the ground truth reference endpoints.
        wav_segs (optional): A pd.DataFrame containing endpoints used prior to VAD segmentation. Only
        required if VAD was applied to subsets of wavefiles rather than the full files. (Default: None)

    Return:
        A dictionary of dictionaries containing TP, FP, FN and TN counts 
    '''

    ref_segs_masks = _segments_to_mask(wav_scp, ref_segs, winlen)
    sys_segs_masks = _segments_to_mask(wav_scp, sys_segs, winlen) 
    if wav_segs is not None:
        wav_segs_masks = _segments_to_mask(wav_scp, wav_segs, winlen)
    scores = {}
    for i in ref_segs_masks:
        if wav_segs is not None:
            score_array = wav_segs_masks[i] * (ref_segs_masks[i] - sys_segs_masks[i])
            num_ground_truth_p = int(np.sum(wav_segs_masks[i] * ref_segs_masks[i]))
            num_frames = int(np.sum(wav_segs_masks[i]))
        else:
            score_array = ref_segs_masks[i] - sys_segs_masks[i]
            num_ground_truth_p = int(np.sum(ref_segs_masks[i]))
            num_frames = len(ref_segs_masks[i])
        num_ground_truth_n = num_frames - num_ground_truth_p
        num_fn = (score_array == 1.0).sum()
        num_fp = (score_array == -1.0).sum()
        num_tp = num_ground_truth_p - num_fn
        num_tn = num_ground_truth_n - num_fp
        scores[i] = {'TP': num_tp, 'FP': num_fp, 'FN': num_fn, 'TN': num_tn}
        
    logging.info("Scores:\n{}".format(pd.DataFrame(scores)))
    print_confusion_matrix(scores)
    
    return scores
Function for calculating the TP, FP, FN and TN counts from VAD segments and ground truth reference segments.

    Args:
        wav_scp: A pd.DataFrame containing information about the wavefiles that have been segmented.
        sys_segs: A pd.DataFrame containing the endpoints produced by a VAD system.
        ref_segs: A pd.DataFrame containing the ground truth reference endpoints.
        wav_segs (optional): A pd.DataFrame containing endpoints used prior to VAD segmentation. Only
        required if VAD was applied to subsets of wavefiles rather than the full files. (Default: None)

    Return:
        A dictionary of dictionaries containing TP, FP, FN and TN counts 
    
Function for calculating the TP, FP, FN and TN counts from VAD segments and ground truth reference segments.
Function for calculating the TP FP FN and TN counts from VAD segments and ground truth reference segments .
def score(wav_scp: pd.DataFrame, sys_segs: pd.DataFrame, ref_segs: pd.DataFrame, wav_segs: pd.DataFrame, winlen: float) -> Dict[str,Dict[str,int]]:
    ref_segs_masks = _segments_to_mask(wav_scp, ref_segs, winlen)
    sys_segs_masks = _segments_to_mask(wav_scp, sys_segs, winlen) 
    if wav_segs is not None:
        wav_segs_masks = _segments_to_mask(wav_scp, wav_segs, winlen)
    scores = {}
    for i in ref_segs_masks:
        if wav_segs is not None:
            score_array = wav_segs_masks[i] * (ref_segs_masks[i] - sys_segs_masks[i])
            num_ground_truth_p = int(np.sum(wav_segs_masks[i] * ref_segs_masks[i]))
            num_frames = int(np.sum(wav_segs_masks[i]))
        else:
            score_array = ref_segs_masks[i] - sys_segs_masks[i]
            num_ground_truth_p = int(np.sum(ref_segs_masks[i]))
            num_frames = len(ref_segs_masks[i])
        num_ground_truth_n = num_frames - num_ground_truth_p
        num_fn = (score_array == 1.0).sum()
        num_fp = (score_array == -1.0).sum()
        num_tp = num_ground_truth_p - num_fn
        num_tn = num_ground_truth_n - num_fp
        scores[i] = {'TP': num_tp, 'FP': num_fp, 'FN': num_fn, 'TN': num_tn}
    logging.info("Scores:\n{}".format(pd.DataFrame(scores)))
    print_confusion_matrix(scores)
    return scores
def score ( wav_scp : pd . DataFrame , sys_segs : pd . DataFrame , ref_segs : pd . DataFrame , wav_segs : pd . DataFrame , winlen : float ) -> Dict [ str , Dict [ str , int ] ] : ref_segs_masks = _segments_to_mask ( wav_scp , ref_segs , winlen ) sys_segs_masks = _segments_to_mask ( wav_scp , sys_segs , winlen ) if wav_segs is not None : wav_segs_masks = _segments_to_mask ( wav_scp , wav_segs , winlen ) scores = { } for i in ref_segs_masks : if wav_segs is not None : score_array = wav_segs_masks [ i ] * ( ref_segs_masks [ i ] - sys_segs_masks [ i ] ) num_ground_truth_p = int ( np . sum ( wav_segs_masks [ i ] * ref_segs_masks [ i ] ) ) num_frames = int ( np . sum ( wav_segs_masks [ i ] ) ) else : score_array = ref_segs_masks [ i ] - sys_segs_masks [ i ] num_ground_truth_p = int ( np . sum ( ref_segs_masks [ i ] ) ) num_frames = len ( ref_segs_masks [ i ] ) num_ground_truth_n = num_frames - num_ground_truth_p num_fn = ( score_array == 1.0 ) . sum ( ) num_fp = ( score_array == - 1.0 ) . sum ( ) num_tp = num_ground_truth_p - num_fn num_tn = num_ground_truth_n - num_fp scores [ i ] = { 'TP' : num_tp , 'FP' : num_fp , 'FN' : num_fn , 'TN' : num_tn } logging . info ( "Scores:\n{}" . format ( pd . DataFrame ( scores ) ) ) print_confusion_matrix ( scores ) return scores
Function for calculating the TP, FP, FN and TN counts from VAD segments and ground truth reference segments.
Function for calculating the TP FP FN and TN counts from VAD segments and ground truth reference segments .
'''Function for calculating the TP, FP, FN and TN counts from VAD segments and ground truth reference segments.

    Args:
        wav_scp: A pd.DataFrame containing information about the wavefiles that have been segmented.
        sys_segs: A pd.DataFrame containing the endpoints produced by a VAD system.
        ref_segs: A pd.DataFrame containing the ground truth reference endpoints.
        wav_segs (optional): A pd.DataFrame containing endpoints used prior to VAD segmentation. Only
        required if VAD was applied to subsets of wavefiles rather than the full files. (Default: None)

    Return:
        A dictionary of dictionaries containing TP, FP, FN and TN counts 
    '''
wav_scp
pd.DataFrame
A pd.DataFrame containing information about the wavefiles that have been segmented.
A pd . DataFrame containing information about the wavefiles that have been segmented .
sys_segs
pd.DataFrame
A pd.DataFrame containing the endpoints produced by a VAD system.
A pd . DataFrame containing the endpoints produced by a VAD system .
ref_segs
pd.DataFrame
A pd.DataFrame containing the ground truth reference endpoints.
A pd . DataFrame containing the ground truth reference endpoints .
wav_segs
pd.DataFrame
A pd.DataFrame containing endpoints used prior to VAD segmentation. Only
A pd . DataFrame containing endpoints used prior to VAD segmentation . Only
winlen
float
required if VAD was applied to subsets of wavefiles rather than the full files. (Default
None