Commit ddf5d699 authored by André Anjos's avatar André Anjos 💬

Merge branch 'fixes' into 'master'

Various fixes

See merge request !82
parents cba0017c 07eef440
Pipeline #21526 passed with stages
in 12 minutes and 49 seconds
......@@ -10,6 +10,12 @@ from . import plot
from . import calibration
import numpy
def fprfnr(negatives, positives, threshold):
"""Alias for :py:func:`bob.measure.farfrr`"""
return farfrr(negatives, positives, threshold)
def mse (estimation, target):
"""Mean square error between a set of outputs and target values
......
......@@ -13,8 +13,9 @@ CRITERIA = ('eer', 'min-hter', 'far')
@common_options.metrics_command(
common_options.METRICS_HELP.format(
names='FtA, FAR, FRR, FMR, FMNR, HTER',
names='FPR, FNR, precision, recall, F1-score',
criteria=CRITERIA, score_format=SCORE_FORMAT,
hter_note=' ',
command='bob measure metrics'),
criteria=CRITERIA)
def metrics(ctx, scores, evaluation, **kwargs):
......
......@@ -8,11 +8,11 @@ import matplotlib.pyplot as plt
import tabulate
from matplotlib.backends.backend_pdf import PdfPages
from bob.extension.scripts.click_helper import (
bool_option, list_float_option, verbosity_option, open_file_mode_option)
bool_option, list_float_option, verbosity_option, open_file_mode_option
)
LOGGER = logging.getLogger(__name__)
def scores_argument(min_arg=1, force_eval=False, **kwargs):
"""Get the argument for scores, and add `dev-scores` and `eval-scores` in
the context when `--eval` flag is on (default)
......@@ -375,6 +375,19 @@ def criterion_option(lcriteria=['eer', 'min-hter', 'far'], **kwargs):
return custom_criterion_option
def decimal_option(dflt=1, **kwargs):
'''Get option to get decimal value'''
def custom_decimal_option(func):
def callback(ctx, param, value):
ctx.meta['decimal'] = value
return value
return click.option(
'-d', '--decimal', type=click.INT, default=dflt,
help='Number of decimals to be printed.',
callback=callback, show_default=True, **kwargs)(func)
return custom_decimal_option
def far_option(**kwargs):
'''Get option to get far value'''
def custom_far_option(func):
......@@ -523,8 +536,8 @@ def titles_option(**kwargs):
'-ts', '--titles', type=click.STRING, default=None,
help='The titles of the plots seperated by commas. '
'For example, if the figure has two plots, \"MyTitleA,MyTitleB\" '
'is a possible input'
'Provide just a space (-t ' ') to '
'is a possible input.'
' Provide just a space (-ts \' \') to '
'remove the titles from figures.',
callback=callback, **kwargs)(func)
return custom_title_option
......@@ -589,6 +602,7 @@ def metrics_command(docstring, criteria=('eer', 'min-hter', 'far')):
@verbosity_option()
@click.pass_context
@functools.wraps(func)
@decimal_option()
def wrapper(*args, **kwds):
return func(*args, **kwds)
return wrapper
......@@ -597,6 +611,7 @@ def metrics_command(docstring, criteria=('eer', 'min-hter', 'far')):
METRICS_HELP = """Prints a table that contains {names} for a given
threshold criterion ({criteria}).
{hter_note}
You need to provide one or more development score file(s) for each
experiment. You can also provide evaluation files along with dev files. If
......@@ -613,6 +628,7 @@ METRICS_HELP = """Prints a table that contains {names} for a given
$ {command} -e -l results.txt sys1/scores-{{dev,eval}}
$ {command} -e {{sys1,sys2}}/scores-{{dev,eval}}
"""
......@@ -791,6 +807,8 @@ def hist_command(docstring):
@print_filenames_option()
@figsize_option(dflt=None)
@style_option()
@x_label_option()
@y_label_option()
@verbosity_option()
@click.pass_context
@functools.wraps(func)
......
This diff is collapsed.
......@@ -159,7 +159,7 @@ def test_hist_legends():
# share same legend for dev/eval of each system
with runner.isolated_filesystem():
result = runner.invoke(commands.hist, ['-e', '-sp', 221, '-ts', 'A,B',
result = runner.invoke(commands.hist, ['-e', '-sp', 111, '-ts', 'A,B',
dev1, test1, dev2, test2])
if result.output:
click.echo(result.output)
......
......@@ -46,7 +46,7 @@ def get_fta(scores):
NaN(s)
:py:class:`float` : failure to acquire rate
"""
fta_sum, fta_total = 0, 0
fta_sum, fta_total = 0.0, 0.0
neg, sum_nans, total = remove_nan(scores[0])
fta_sum += sum_nans
fta_total += total
......
This diff is collapsed.
......@@ -24,6 +24,7 @@ Single point measurements
.. autosummary::
bob.measure.eer
bob.measure.fprfnr
bob.measure.farfrr
bob.measure.f_score
bob.measure.precision_recall
......
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