Commit 4b5fa1c1 authored by André Anjos's avatar André Anjos 💬

Completely removes argparse requirement

parent c51614d9
Pipeline #4151 passed with stages
in 13 minutes and 29 seconds
......@@ -33,6 +33,11 @@ Examples:
import os
import sys
import logging
__logging_format__='[%(levelname)s] %(message)s'
logging.basicConfig(format=__logging_format__)
logger = logging.getLogger('bob')
from .eval_threshold import apthres
......@@ -57,6 +62,10 @@ def main(user_input=None):
version=completions['version'],
)
# Sets-up logging
if args['--verbose'] == 1: logging.getLogger().setLevel(logging.INFO)
elif args['--verbose'] >= 2: logging.getLogger().setLevel(logging.DEBUG)
# handles threshold validation
try:
args['<threshold>'] = float(args['<threshold>'])
......
......@@ -58,7 +58,7 @@ logger = logging.getLogger('bob')
def print_crit(dev_neg, dev_pos, test_neg, test_pos, crit):
"""Prints a single output line that contains all info for a given criterium"""
"""Prints a single output line that contains all info for a given criterion"""
from .. import eer_threshold, min_hter_threshold, farfrr
......@@ -73,7 +73,7 @@ def print_crit(dev_neg, dev_pos, test_neg, test_pos, crit):
test_far, test_frr = farfrr(test_neg, test_pos, thres)
test_hter = (test_far + test_frr)/2.0
print("[Min. criterium: %s] Threshold on Development set: %e" % (crit, thres))
print("[Min. criterion: %s] Threshold on Development set: %e" % (crit, thres))
dev_ni = dev_neg.shape[0] #number of impostors
dev_fa = int(round(dev_far*dev_ni)) #number of false accepts
......
......@@ -19,11 +19,11 @@ Options:
-h, --help Shows this help message and exits
-V, --version Prints the version and exits
-v, --verbose Increases the output verbosity level
-c <crit>, --criterium=<crit> The minimization criterium to use (choose
-c <crit>, --criterion=<crit> The minimization criterion to use (choose
between mhter, mwer or eer) [default: eer]
-w <float>, --cost=<float> The value w of the cost when minimizing using
the minimum weighter error rate (mwer)
criterium. This value is ignored for eer or
criterion. This value is ignored for eer or
mhter criteria. [default: 0.5]
......@@ -31,11 +31,11 @@ Examples:
1. Specify a different criteria (only mhter, mwer or eer accepted):
$ %(prog)s --criterium=mhter scores.txt
$ %(prog)s --criterion=mhter scores.txt
2. Calculate the threshold that minimizes the weither HTER for a cost of 0.4:
$ %(prog)s --criterium=mwer --cost=0.4 scores.txt
$ %(prog)s --criterion=mwer --cost=0.4 scores.txt
3. Parse your input using a 5-column format
......@@ -47,6 +47,11 @@ Examples:
import os
import sys
import logging
__logging_format__='[%(levelname)s] %(message)s'
logging.basicConfig(format=__logging_format__)
logger = logging.getLogger('bob')
def apthres(neg, pos, thres):
"""Prints a single output line that contains all info for the threshold"""
......@@ -102,10 +107,14 @@ def main(user_input=None):
version=completions['version'],
)
# validates criterium
# Sets-up logging
if args['--verbose'] == 1: logging.getLogger().setLevel(logging.INFO)
elif args['--verbose'] >= 2: logging.getLogger().setLevel(logging.DEBUG)
# validates criterion
valid_criteria = ('eer', 'mhter', 'mwer')
if args['--criterium'] not in valid_criteria:
raise docopt.DocoptExit("--criterium must be one of %s" % \
if args['--criterion'] not in valid_criteria:
raise docopt.DocoptExit("--criterion must be one of %s" % \
', '.join(valid_criteria))
# handles cost validation
......@@ -121,7 +130,7 @@ def main(user_input=None):
from ..load import load_score, get_negatives_positives
neg, pos = get_negatives_positives(load_score(args['<scores>']))
t = calculate(neg, pos, args['--criterium'], args['--cost'])
t = calculate(neg, pos, args['--criterion'], args['--cost'])
print("Threshold:", t)
apthres(neg, pos, t)
......
This diff is collapsed.
......@@ -482,13 +482,13 @@ evaluation and plotting of development and test set data using our combined
.. code-block:: sh
$ bob_compute_perf.py --devel=development-scores-4col.txt --test=test-scores-4col.txt
[Min. criterium: EER] Threshold on Development set: -4.787956e-03
[Min. criterion: EER] Threshold on Development set: -4.787956e-03
| Development | Test
-------+-----------------+------------------
FAR | 6.731% (35/520) | 2.500% (13/520)
FRR | 6.667% (26/390) | 6.154% (24/390)
HTER | 6.699% | 4.327%
[Min. criterium: Min. HTER] Threshold on Development set: 3.411070e-03
[Min. criterion: Min. HTER] Threshold on Development set: 3.411070e-03
| Development | Test
-------+-----------------+------------------
FAR | 4.231% (22/520) | 1.923% (10/520)
......
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