Commit 0a9b0728 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch 'theo' into 'master'

Change variable name form criter to criterion

See merge request !58
parents bca2a42a cf03a121
Pipeline #19482 passed with stages
in 46 minutes and 54 seconds
...@@ -235,12 +235,12 @@ def evaluate(ctx, scores, evaluation, **kwargs): ...@@ -235,12 +235,12 @@ def evaluate(ctx, scores, evaluation, **kwargs):
# first time erase if existing file # first time erase if existing file
ctx.meta['open_mode'] = 'w' ctx.meta['open_mode'] = 'w'
click.echo("Computing metrics with EER...") click.echo("Computing metrics with EER...")
ctx.meta['criter'] = 'eer' # no criterion passed to evaluate ctx.meta['criterion'] = 'eer' # no criterion passed to evaluate
ctx.invoke(metrics, scores=scores, evaluation=evaluation) ctx.invoke(metrics, scores=scores, evaluation=evaluation)
# second time, appends the content # second time, appends the content
ctx.meta['open_mode'] = 'a' ctx.meta['open_mode'] = 'a'
click.echo("Computing metrics with HTER...") click.echo("Computing metrics with HTER...")
ctx.meta['criter'] = 'hter' # no criterion passed in evaluate ctx.meta['criterion'] = 'hter' # no criterion passed in evaluate
ctx.invoke(metrics, scores=scores, evaluation=evaluation) ctx.invoke(metrics, scores=scores, evaluation=evaluation)
if 'log' in ctx.meta: if 'log' in ctx.meta:
click.echo("[metrics] => %s" % ctx.meta['log']) click.echo("[metrics] => %s" % ctx.meta['log'])
...@@ -262,7 +262,7 @@ def evaluate(ctx, scores, evaluation, **kwargs): ...@@ -262,7 +262,7 @@ def evaluate(ctx, scores, evaluation, **kwargs):
# the last one closes the file # the last one closes the file
ctx.meta['closef'] = True ctx.meta['closef'] = True
click.echo("Computing score histograms...") click.echo("Computing score histograms...")
ctx.meta['criter'] = 'eer' # no criterion passed in evaluate ctx.meta['criterion'] = 'eer' # no criterion passed in evaluate
ctx.forward(hist) ctx.forward(hist)
click.echo("Evaluate successfully completed!") click.echo("Evaluate successfully completed!")
click.echo("[plots] => %s" % (ctx.meta['output'])) click.echo("[plots] => %s" % (ctx.meta['output']))
...@@ -256,7 +256,7 @@ def criterion_option(lcriteria=['eer', 'hter', 'far'], **kwargs): ...@@ -256,7 +256,7 @@ def criterion_option(lcriteria=['eer', 'hter', 'far'], **kwargs):
raise click.BadParameter('Incorrect value for `--criterion`. ' raise click.BadParameter('Incorrect value for `--criterion`. '
'Must be one of [`%s`]' % 'Must be one of [`%s`]' %
'`, `'.join(list_accepted_crit)) '`, `'.join(list_accepted_crit))
ctx.meta['criter'] = value ctx.meta['criterion'] = value
return value return value
return click.option( return click.option(
'--criterion', default='eer', help='Criterion to compute plots and ' '--criterion', default='eer', help='Criterion to compute plots and '
......
...@@ -156,7 +156,8 @@ class Metrics(MeasureBase): ...@@ -156,7 +156,8 @@ class Metrics(MeasureBase):
super(Metrics, self).__init__(ctx, scores, evaluation, func_load) super(Metrics, self).__init__(ctx, scores, evaluation, func_load)
self._tablefmt = None if 'tablefmt' not in ctx.meta else\ self._tablefmt = None if 'tablefmt' not in ctx.meta else\
ctx.meta['tablefmt'] ctx.meta['tablefmt']
self._criter = None if 'criter' not in ctx.meta else ctx.meta['criter'] self._criterion = None if 'criterion' not in ctx.meta else \
ctx.meta['criterion']
self._open_mode = None if 'open_mode' not in ctx.meta else\ self._open_mode = None if 'open_mode' not in ctx.meta else\
ctx.meta['open_mode'] ctx.meta['open_mode']
self._thres = None if 'thres' not in ctx.meta else ctx.meta['thres'] self._thres = None if 'thres' not in ctx.meta else ctx.meta['thres']
...@@ -185,15 +186,17 @@ class Metrics(MeasureBase): ...@@ -185,15 +186,17 @@ class Metrics(MeasureBase):
eval_neg, eval_pos, eval_fta = neg_list[1], pos_list[1], fta_list[1] eval_neg, eval_pos, eval_fta = neg_list[1], pos_list[1], fta_list[1]
eval_file = input_names[1] eval_file = input_names[1]
threshold = utils.get_thres(self._criter, dev_neg, dev_pos, self._far) \ threshold = utils.get_thres(self._criterion, dev_neg, dev_pos, self._far) \
if self._thres is None else self._thres[idx] if self._thres is None else self._thres[idx]
title = self._titles[idx] if self._titles is not None else None title = self._titles[idx] if self._titles is not None else None
if self._thres is None: if self._thres is None:
far_str = '' far_str = ''
if self._criter == 'far' and self._far is not None: if self._criterion == 'far' and self._far is not None:
far_str = str(self._far) far_str = str(self._far)
click.echo("[Min. criterion: %s %s] Threshold on Development set `%s`: %e"\ click.echo("[Min. criterion: %s %s] Threshold on Development set `%s`: %e"\
% (self._criter.upper(), far_str, title or dev_file, threshold), % (self._criterion.upper(),
far_str, title or dev_file,
threshold),
file=self.log_file) file=self.log_file)
else: else:
click.echo("[Min. criterion: user provider] Threshold on " click.echo("[Min. criterion: user provider] Threshold on "
...@@ -532,7 +535,8 @@ class Hist(PlotBase): ...@@ -532,7 +535,8 @@ class Hist(PlotBase):
'#thresholds must be the same as #systems (%d)' \ '#thresholds must be the same as #systems (%d)' \
% self.n_systems % self.n_systems
) )
self._criter = None if 'criter' not in ctx.meta else ctx.meta['criter'] self._criterion = None if 'criterion' not in ctx.meta else \
ctx.meta['criterion']
self._y_label = 'Dev. probability density' if self._eval else \ self._y_label = 'Dev. probability density' if self._eval else \
'density' or self._y_label 'density' or self._y_label
self._x_label = 'Scores' if not self._eval else '' self._x_label = 'Scores' if not self._eval else ''
...@@ -617,7 +621,7 @@ class Hist(PlotBase): ...@@ -617,7 +621,7 @@ class Hist(PlotBase):
eval_pos = [pos_list[x] for x in range(1, length, 2)] eval_pos = [pos_list[x] for x in range(1, length, 2)]
threshold = utils.get_thres( threshold = utils.get_thres(
self._criter, dev_neg[0], dev_pos[0] self._criterion, dev_neg[0], dev_pos[0]
) if self._thres is None else self._thres[idx] ) if self._thres is None else self._thres[idx]
return dev_neg, dev_pos, eval_neg, eval_pos, threshold return dev_neg, dev_pos, eval_neg, eval_pos, threshold
...@@ -630,7 +634,7 @@ class Hist(PlotBase): ...@@ -630,7 +634,7 @@ class Hist(PlotBase):
return (n, bins, patches) return (n, bins, patches)
def _lines(self, threshold, neg=None, pos=None, **kwargs): def _lines(self, threshold, neg=None, pos=None, **kwargs):
label = 'Threshold' if self._criter is None else self._criter.upper() label = 'Threshold' if self._criterion is None else self._criterion.upper()
kwargs.setdefault('color', 'C3') kwargs.setdefault('color', 'C3')
kwargs.setdefault('linestyle', '--') kwargs.setdefault('linestyle', '--')
kwargs.setdefault('label', label) kwargs.setdefault('label', label)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment