Commit a2640f7d authored by Theophile GENTILHOMME's avatar Theophile GENTILHOMME

Ensure subplots of histograms are corectly displayed

parent c30bdb46
Pipeline #19738 canceled with stage
in 9 seconds
......@@ -28,7 +28,7 @@ def weighted_neg_error_rate_criteria(data,
"""Given the single value for the weight parameter balancing between
impostors and spoofing attacks and a threshold, calculates the error rates
and their relationship depending on the criteria (difference in case of
'eer', hter in case of 'hter' criteria)
'eer', hter in case of 'min-hter' criteria)
Keyword parameters:
- data - the development data used to determine the threshold. List on 4
......@@ -40,8 +40,8 @@ def weighted_neg_error_rate_criteria(data,
- beta - the weight parameter balancing between real accesses and all the
negative samples (impostors and spoofing attacks). Note that this
parameter will be overriden and not considered if the selected criteria
is 'hter'.
- criteria - 'eer', 'wer' or 'hter' criteria for decision threshold
is 'min-hter'.
- criteria - 'eer', 'wer' or 'min-hter' criteria for decision threshold
"""
licit_neg = data[0]
......@@ -64,7 +64,7 @@ def weighted_neg_error_rate_criteria(data,
#return abs(far_w - frr)
return abs((1 - beta) * frr - beta * far_w)
elif criteria == 'hter':
elif criteria == 'min-hter':
return (far_w + frr) / 2
else:
......@@ -94,9 +94,9 @@ def recursive_thr_search(data,
- beta - the weight parameter balancing between real accesses and all the
negative samples (impostors and spoofing attacks). Note that methods called
within this function will override this parameter and not considered if the
selected criteria is 'hter'.
selected criteria is 'min-hter'.
- criteria - the decision threshold criteria ('eer' for EER, 'wer' for
Minimum WER or 'hter' for Minimum HTER criteria).
Minimum WER or 'min-hter' for Minimum HTER criteria).
"""
quit_thr = 1e-10
......@@ -144,9 +144,9 @@ def weighted_negatives_threshold(licit_neg,
- beta - the weight parameter balancing between real accesses and all the
negative samples (impostors and spoofing attacks). Note that methods called
within this function will override this parameter and not considered if the
selected criteria is 'hter'.
selected criteria is 'min-hter'.
- criteria - the decision threshold criteria ('eer' for EER, 'wer' for
Minimum WER or 'hter' for Minimum HTER criteria).
Minimum WER or 'min-hter' for Minimum HTER criteria).
"""
span_min = min(
numpy.append(licit_neg, spoof_neg)
......@@ -192,7 +192,7 @@ def epsc_thresholds(licit_neg,
- spoof_neg - numpy.array of scores for the negatives (spoof scenario)
- spoof_pos - numpy.array of scores for the positives (spoof scenario)
- points - number of points to calculate EPSC
- criteria - the decision threshold criteria ('eer', 'wer' or 'hter')
- criteria - the decision threshold criteria ('eer', 'wer' or 'min-hter')
- omega - the value of the parameter omega, balancing between impostors and
spoofing attacks. If None, it is going to span the full range [0,1].
Otherwise, can be set to a fixed value or a list of values.
......@@ -414,7 +414,7 @@ def calc_aue(licit_neg,
- l_bound - lower bound of integration
- h_bound - higher bound of integration
- points - number of points to calculate EPSC
- criteria - the decision threshold criteria ('eer', 'wer' or 'hter')
- criteria - the decision threshold criteria ('eer', 'wer' or 'min-hter')
- var_param - name of the parameter which is varied on the abscissa
('omega' or 'beta')
"""
......
......@@ -157,10 +157,10 @@ class HistVuln(measure_figure.Hist):
hatch='\\\\'
)
def _lines(self, threshold, neg, pos, **kwargs):
def _lines(self, threshold, label, neg, pos, idx, **kwargs):
if 'iapmr_line' not in self._ctx.meta or self._ctx.meta['iapmr_line']:
#plot vertical line
super(HistVuln, self)._lines(threshold, neg, pos)
super(HistVuln, self)._lines(threshold, label, neg, pos, idx)
#plot iapmr_line
iapmr, _ = farfrr(neg[1], pos[0], threshold)
......@@ -172,12 +172,16 @@ class HistVuln(measure_figure.Hist):
far, frr = farfrr(neg[0], pos[0], threshold)
_iapmr_plot(neg[1], threshold, iapmr, real_data=real_data)
click.echo(
'HTER (t=%.2g) = %.2f%%; IAPMR = %.2f%%' % (
'%s (t=%.2g) = %.2f%%; IAPMR = %.2f%%' % (
self._criterion.upper(),
threshold,
50*(far+frr), 100*iapmr
)
)
n = idx % self._step_print
col = n % self._ncols
rest_print = self.n_systems - int(idx / self._step_print) * self._step_print
if col == self._ncols - 1 or n == rest_print - 1:
ax2.set_ylabel("IAPMR (%)", color='C3')
ax2.tick_params(axis='y', colors='red')
ax2.yaxis.label.set_color('red')
......
......@@ -8,16 +8,18 @@ from . import figure
@click.command()
@common_options.scores_argument(nargs=-1)
@common_options.title_option()
@common_options.output_plot_file_option(default_out='hist.pdf')
@common_options.eval_option()
@common_options.n_bins_option()
@common_options.criterion_option()
@common_options.thresholds_option()
@common_options.const_layout_option()
@common_options.show_dev_option()
@common_options.print_filenames_option(dflt=False)
@common_options.legends_option()
@common_options.figsize_option()
@common_options.figsize_option(dflt=None)
@common_options.subplot_option()
@common_options.legend_ncols_option()
@common_options.style_option()
@verbosity_option()
@click.pass_context
......@@ -40,20 +42,20 @@ def hist(ctx, scores, evaluation, **kwargs):
$ bob pad hist dev-scores1 eval-scores1 dev-scores2
eval-scores2
$ bob pad hist --criterion hter dev-scores1 eval-scores1
$ bob pad hist --criterion min-hter dev-scores1 eval-scores1
"""
process = figure.HistPad(ctx, scores, evaluation, load.split)
process.run()
@click.command()
@common_options.scores_argument(nargs=-1, min_arg=2)
@common_options.title_option()
@common_options.output_plot_file_option(default_out='vuln.pdf')
@common_options.eval_option()
@common_options.n_bins_option()
@common_options.criterion_option()
@common_options.thresholds_option()
@common_options.const_layout_option()
@common_options.show_dev_option()
@common_options.print_filenames_option(dflt=False)
@bool_option(
'iapmr-line', 'I', 'Whether to plot the IAPMR related lines or not.', True
......@@ -64,7 +66,9 @@ def hist(ctx, scores, evaluation, **kwargs):
'of with real data values of the calculated error rates.', True
)
@common_options.legends_option()
@common_options.figsize_option()
@common_options.figsize_option(dflt=None)
@common_options.subplot_option()
@common_options.legend_ncols_option()
@common_options.style_option()
@verbosity_option()
@click.pass_context
......
......@@ -62,7 +62,7 @@ def test_hist():
assert result.exit_code == 0, (result.exit_code, result.output)
with runner.isolated_filesystem():
result = runner.invoke(histograms.hist, ['--criterion', 'hter', '--output',
result = runner.invoke(histograms.hist, ['--criterion', 'min-hter', '--output',
'HISTO.pdf', '-b',
'30,auto', '--no-evaluation',
licit_dev, spoof_dev])
......
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