Coverage for src/bob/bio/face/reports/gbu.py: 0%

32 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2024-07-13 00:04 +0200

1import matplotlib.pyplot as plt 

2 

3from matplotlib.backends.backend_pdf import PdfPages 

4 

5import bob.measure 

6 

7from bob.bio.base.score.load import get_split_dataframe 

8 

9 

10def gbu_report(scores_dev, output_filename, titles, figsize=(8, 6)): 

11 colors = plt.cm.tab20.colors 

12 

13 # Plotting 

14 pdf = PdfPages(output_filename) 

15 

16 # Figure for eval plot 

17 fig = plt.figure(figsize=figsize) 

18 ax = fig.add_subplot(111) 

19 

20 for d_scores, title, color in zip(scores_dev, titles, colors): 

21 # Load the score files and fill in the angle associated to each camera 

22 impostors_dev, genuines_dev = get_split_dataframe(d_scores) 

23 

24 # loading the dask dataframes 

25 i_dev = impostors_dev["score"].compute().to_numpy() 

26 g_dev = genuines_dev["score"].compute().to_numpy() 

27 

28 fmr, fnmr = bob.measure.roc(i_dev, g_dev, n_points=40) 

29 # in % 

30 fnmr = 1 - fnmr 

31 fnmr *= 100 

32 fmr *= 100 

33 

34 # plot.plot(roc_curve) 

35 plt.semilogx(fmr, fnmr, marker="o", label=title) 

36 pass 

37 

38 pass 

39 

40 # Plot finalization 

41 # plt.title(f"FMR vs FNMR . at Dev. FMR@{fmr_threshold}") 

42 ax.set_xlabel("FMR%", fontsize=18) 

43 ax.set_ylabel("1 - FNMR%", fontsize=18) 

44 

45 x_ticks = [0.0001, 0.01, 1, 100] 

46 ax.set_xticks(x_ticks) 

47 ax.set_xticklabels([f"{x}%" for x in x_ticks], fontsize=14) 

48 

49 y_ticks = [0, 20, 40, 60, 80, 100] 

50 ax.set_yticks(y_ticks) 

51 ax.set_yticklabels([f"{x}%" for x in y_ticks], fontsize=14) 

52 

53 plt.legend() 

54 plt.grid() 

55 

56 pdf.savefig(fig) 

57 pdf.close()