linkability()¶
- audmetric.linkability(truth, prediction, omega=1.0, nbins=None)[source]¶
Linkability for verification tasks.
Let be the provided prediction score for the similarity of the tested sample. The clipped local linkability metric is then defined as:
The higher the value, the more likely that an attacker can link two mated samples. The global linkability metric is the mean value over all local scores,[1] and in the range and .
Implementation is based on code from M. Maouche, which is licensed under LGPL.
- Parameters:
truth (
bool|int|Sequence[bool|int]) – ground truth classesprediction (
bool|int|float|Sequence[bool|int|float]) – predicted classes or similarity scoresomega (
float) – prior rationbins (
int) – number of bins of the histograms that estimate the distributions of mated and non-mated scores. IfNoneit is set to
- Return type:
float- Returns:
global linkability
- Raises:
ValueError – if
truthcontains values different from1,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