From 29448290834a92c31ff737a846e41ea37a1517d3 Mon Sep 17 00:00:00 2001 From: Tiago Freitas Pereira <tiagofrepereira@gmail.com> Date: Tue, 29 Aug 2017 11:46:04 +0200 Subject: [PATCH] Allowing eval DIR curve to use the dev thresholds --- bob/bio/base/script/evaluate.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bob/bio/base/script/evaluate.py b/bob/bio/base/script/evaluate.py index b239e235..325229d7 100644 --- a/bob/bio/base/script/evaluate.py +++ b/bob/bio/base/script/evaluate.py @@ -193,7 +193,7 @@ def _plot_cmc(cmcs, colors, labels, title, fontsize=10, position=None): return figure -def _plot_dir(cmc_scores, far_values, rank, colors, labels, title, fontsize=10, position=None): +def _plot_dir(cmc_scores, far_values, rank, colors, labels, title, fontsize=10, position=None, thresholds=None): if position is None: position = 'lower right' # open new page for current plot figure = pyplot.figure() @@ -206,7 +206,8 @@ def _plot_dir(cmc_scores, far_values, rank, colors, labels, title, fontsize=10, raise ValueError("There need to be at least one pair with only negative scores") # compute thresholds based on FAR values - thresholds = [bob.measure.far_threshold(negatives, [], v, True) for v in far_values] + if thresholds is None: + thresholds = [bob.measure.far_threshold(negatives, [], v, True) for v in far_values] # compute detection and identification rate based on the thresholds for # the given rank @@ -223,7 +224,7 @@ def _plot_dir(cmc_scores, far_values, rank, colors, labels, title, fontsize=10, pyplot.legend(loc=position, prop = {'size':fontsize}) pyplot.title(title) - return figure + return figure, thresholds def _plot_epc(scores_dev, scores_eval, colors, labels, title, fontsize=10, position=None): @@ -452,9 +453,10 @@ def main(command_line_parameters=None): # create a multi-page PDF for the DIR curve pdf = PdfPages(args.dir) # create a separate figure for dev and eval - pdf.savefig(_plot_dir(cmcs_dev, fars, args.rank, colors, args.legends, args.title[0] if args.title is not None else "DIR curve for development set", args.legend_font_size, args.legend_position), bbox_inches='tight') + figure, thresholds = _plot_dir(cmcs_dev, fars, args.rank, colors, args.legends, args.title[0] if args.title is not None else "DIR curve for development set", args.legend_font_size, args.legend_position) + pdf.savefig(figure, bbox_inches='tight') if args.eval_files: - pdf.savefig(_plot_dir(cmcs_eval, fars, args.rank, colors, args.legends, args.title[1] if args.title is not None else "DIR curve for evaluation set", args.legend_font_size, args.legend_position), bbox_inches='tight') + pdf.savefig(_plot_dir(cmcs_eval, fars, args.rank, colors, args.legends, args.title[1] if args.title is not None else "DIR curve for evaluation set", args.legend_font_size, args.legend_position, thresholds=thresholds)[0], bbox_inches='tight') pdf.close() except RuntimeError as e: raise RuntimeError("During plotting of DIR curves, the following exception occured:\n%s") -- GitLab