espnet2.utils.eer.ComputeErrorRates
Less than 1 minute
espnet2.utils.eer.ComputeErrorRates
espnet2.utils.eer.ComputeErrorRates(scores, labels)
Computes the false-negative rates (FNRs) and false-positive rates (FPRs)
based on the provided scores and labels. This function sorts the scores and calculates the corresponding FNRs and FPRs at various decision thresholds.
- Parameters:
- scores (list or numpy.ndarray) – A list or array of scores to evaluate.
- labels (list or numpy.ndarray) – A list or array of binary labels corresponding to the scores (1 for positive, 0 for negative).
- Returns: A tuple containing: : - fnrs (list): A list of false-negative rates corresponding to the thresholds.
- fprs (list): A list of false-positive rates corresponding to the thresholds.
- thresholds (list): A list of thresholds used to calculate the FNRs and FPRs.
- Return type: tuple
Examples
>>> scores = [0.1, 0.4, 0.35, 0.8]
>>> labels = [0, 0, 1, 1]
>>> fnrs, fprs, thresholds = ComputeErrorRates(scores, labels)
>>> print(fnrs)
[0.0, 0.5, 1.0]
>>> print(fprs)
[1.0, 0.5, 0.0]
>>> print(thresholds)
[0.1, 0.35, 0.4, 0.8]
NOTE
The output FNRs and FPRs are normalized by the total number of positive and negative samples, respectively.