Coverage for src/bob/measure/script/commands.py: 91%

32 statements  

« prev     ^ index     » next       coverage.py v7.0.5, created at 2023-06-16 14:10 +0200

1""" Click commands for ``bob.measure`` """ 

2 

3from .. import load 

4from . import common_options, figure 

5 

6SCORE_FORMAT = ( 

7 "The command takes as input generic 2-column data format as " 

8 "specified in the documentation of " 

9 ":py:func:`bob.measure.load.split`." 

10) 

11CRITERIA = ("eer", "min-hter", "far") 

12 

13 

14@common_options.metrics_command( 

15 common_options.METRICS_HELP.format( 

16 names="FPR, FNR, precision, recall, F1-score, AUC ROC", 

17 criteria=CRITERIA, 

18 score_format=SCORE_FORMAT, 

19 hter_note=" ", 

20 command="bob measure metrics", 

21 ), 

22 criteria=CRITERIA, 

23 far_name="FPR", 

24) 

25def metrics(ctx, scores, evaluation, **kwargs): 

26 process = figure.Metrics(ctx, scores, evaluation, load.split) 

27 process.run() 

28 

29 

30@common_options.roc_command( 

31 common_options.ROC_HELP.format( 

32 score_format=SCORE_FORMAT, command="bob measure roc" 

33 ), 

34 far_name="FPR", 

35) 

36def roc(ctx, scores, evaluation, **kwargs): 

37 process = figure.Roc(ctx, scores, evaluation, load.split) 

38 process.run() 

39 

40 

41@common_options.det_command( 

42 common_options.DET_HELP.format( 

43 score_format=SCORE_FORMAT, command="bob measure det" 

44 ), 

45 far_name="FPR", 

46) 

47def det(ctx, scores, evaluation, **kwargs): 

48 process = figure.Det(ctx, scores, evaluation, load.split) 

49 process.run() 

50 

51 

52@common_options.epc_command( 

53 common_options.EPC_HELP.format( 

54 score_format=SCORE_FORMAT, command="bob measure epc" 

55 ) 

56) 

57def epc(ctx, scores, **kwargs): 

58 process = figure.Epc(ctx, scores, True, load.split) 

59 process.run() 

60 

61 

62@common_options.hist_command( 

63 common_options.HIST_HELP.format( 

64 score_format=SCORE_FORMAT, command="bob measure hist" 

65 ), 

66 far_name="FPR", 

67) 

68def hist(ctx, scores, evaluation, **kwargs): 

69 process = figure.Hist(ctx, scores, evaluation, load.split) 

70 process.run() 

71 

72 

73@common_options.evaluate_command( 

74 common_options.EVALUATE_HELP.format( 

75 score_format=SCORE_FORMAT, command="bob measure evaluate" 

76 ), 

77 criteria=CRITERIA, 

78 far_name="FPR", 

79) 

80def evaluate(ctx, scores, evaluation, **kwargs): 

81 common_options.evaluate_flow( 

82 ctx, scores, evaluation, metrics, roc, det, epc, hist, **kwargs 

83 ) 

84 

85 

86@common_options.multi_metrics_command( 

87 common_options.MULTI_METRICS_HELP.format( 

88 names="FtA, FAR, FRR, FMR, FMNR, HTER", 

89 criteria=CRITERIA, 

90 score_format=SCORE_FORMAT, 

91 command="bob measure multi-metrics", 

92 ), 

93 criteria=CRITERIA, 

94 far_name="FPR", 

95) 

96def multi_metrics(ctx, scores, evaluation, protocols_number, **kwargs): 

97 ctx.meta["min_arg"] = protocols_number * (2 if evaluation else 1) 

98 process = figure.MultiMetrics(ctx, scores, evaluation, load.split) 

99 process.run()