def print_table(file_to_scores, global_scores, n_digits=2, table_format='simple'): """Pretty print scores as table. Parameters ---------- file_to_scores : dict Mapping from file ids in ``uem`` to ``Scores`` instances. global_scores : Scores Global scores. n_digits : int, optional Number of decimal digits to display. (Default: 3) table_format : str, optional Table format. Passed to ``tabulate.tabulate``. (Default: 'simple') """ col_names = [ 'File', 'DER', # Diarization error rate. 'B3-Precision', # B-cubed precision. 'B3-Recall', # B-cubed recall. 'B3-F1', # B-cubed F1. 'GKT(ref, sys)', # Goodman-Krustal tau (ref, sys). 'GKT(sys, ref)', # Goodman-Kruskal tau (sys, ref). 'H(ref|sys)', # Conditional entropy of ref given sys. 'H(sys|ref)', # Conditional entropy of sys given ref. 'MI', # Mutual information. 'NMI', # Normalized mutual information. ] rows = [] for file_id in sorted(iterkeys(file_to_scores)): scores = file_to_scores[file_id] row = [ file_id, scores.der, scores.bcubed_precision, scores.bcubed_recall, scores.bcubed_f1, scores.tau_ref_sys, scores.tau_sys_ref, scores.ce_ref_sys, scores.ce_sys_ref, scores.mi, scores.nmi ] rows.append(row) rows.append([ '*** OVERALL ***', global_scores.der, global_scores.bcubed_precision, global_scores.bcubed_recall, global_scores.bcubed_f1, global_scores.tau_ref_sys, global_scores.tau_sys_ref, global_scores.ce_ref_sys, global_scores.ce_sys_ref, global_scores.mi, global_scores.nmi ]) floatfmt = '.%df' % n_digits tbl = tabulate(rows, headers=col_names, floatfmt=floatfmt, tablefmt=table_format) print(tbl)
def check_for_empty_files(ref_turns, sys_turns, uem): """Warn on files in UEM without reference or speaker turns.""" ref_file_ids = {turn.file_id for turn in ref_turns} sys_file_ids = {turn.file_id for turn in sys_turns} for file_id in sorted(iterkeys(uem)): if file_id not in ref_file_ids: warn('File "%s" missing in reference RTTMs.' % file_id) if file_id not in sys_file_ids: warn('File "%s" missing in system RTTMs.' % file_id) # TODO: Clarify below warnings; this indicates that there are no # ELIGIBLE reference/system turns. if not ref_turns: warn('No reference speaker turns found within UEM scoring regions.') if not sys_turns: warn('No system speaker turns found within UEM scoring regions.')