linkability()

audmetric.linkability(truth, prediction, omega=1.0, nbins=None)[source]

Linkability for verification tasks.

Let ss be the provided prediction score for the similarity of the tested sample. The clipped local linkability metric is then defined as:

max(0,p(mateds)p(non-mateds))\text{max}(0, p(\text{mated} | s) - p(\text{non-mated} | s))

The higher the value, the more likely that an attacker can link two mated samples. The global linkability metric DsysD_\text{sys} is the mean value over all local scores,1 and in the range 00 and 11.

Implementation is based on code from M. Maouche, which is licensed under LGPL.

1

M. Gomez-Barrero, J. Galbally, C. Rathgeb, and C. Busch. General framework to evaluate unlinkability in biometric template protection systems. IEEE Transactions on Information Forensics and Security, 13:1406–1420, 2017. doi:10.1109/TIFS.2017.2788000.

Parameters
  • truth (Union[bool, int, Sequence[Union[bool, int]]]) – ground truth classes

  • prediction (Union[bool, int, float, Sequence[Union[bool, int, float]]]) – predicted classes or similarity scores

  • omega (float) – prior ratio p(mated)p(non-mated)\frac{p(\text{mated})}{p(\text{non-mated})}

  • nbins (Optional[int]) – number of bins of the histograms that estimate the distributions of mated and non-mated scores. If None it is set to min(len(mated)10,100)\min(\frac{\text{len}(\text{mated})}{10}, 100)

Return type

float

Returns

global linkability DsysD_\text{sys}

Raises

ValueError – if truth contains values different from 1, 0, True, False

Examples

>>> np.random.seed(1)
>>> samples = 10000
>>> truth = [1, 0] * int(samples / 2)
>>> prediction = []
>>> for _ in range(int(samples / 2)):
...     prediction.extend([np.random.uniform(0, 0.2), np.random.uniform(0.8, 1.0)])
>>> linkability(truth, prediction)
0.9747999999999999
>>> truth = [1, 0, 0, 0] * int(samples / 4)
>>> prediction = [np.random.uniform(0, 1) for _ in range(samples)]
>>> linkability(truth, prediction, omega=1 / 3)
0.0