Commit b9c497b3 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

Add a helper eer function

parent a6e32312
Pipeline #20897 passed with stage
in 15 minutes and 37 seconds
...@@ -168,7 +168,7 @@ def recognition_rate(cmc_scores, threshold = None, rank = 1): ...@@ -168,7 +168,7 @@ def recognition_rate(cmc_scores, threshold = None, rank = 1):
Parameters: Parameters:
cmc_scores (:py:class:`list`): A list in the format ``[(negatives, cmc_scores (:py:class:`list`): A list in the format ``[(negatives,
positives), ...]`` containing the CMC scores (i.e. :py:class:`list`: positives), ...]`` containing the CMC scores (i.e. :py:class:`list`:
A list of tuples, where each tuple contains the A list of tuples, where each tuple contains the
``negative`` and ``positive`` scores for one probe of the database). ``negative`` and ``positive`` scores for one probe of the database).
...@@ -395,7 +395,7 @@ def false_alarm_rate(cmc_scores, threshold): ...@@ -395,7 +395,7 @@ def false_alarm_rate(cmc_scores, threshold):
Parameters: Parameters:
cmc_scores (:py:class:`list`): A list in the format ``[(negatives, cmc_scores (:py:class:`list`): A list in the format ``[(negatives,
positives), ...]`` containing the CMC scores (i.e. :py:class:`list`: positives), ...]`` containing the CMC scores (i.e. :py:class:`list`:
A list of tuples, where each tuple contains the A list of tuples, where each tuple contains the
``negative`` and ``positive`` scores for one probe of the database). ``negative`` and ``positive`` scores for one probe of the database).
...@@ -431,6 +431,42 @@ def false_alarm_rate(cmc_scores, threshold): ...@@ -431,6 +431,42 @@ def false_alarm_rate(cmc_scores, threshold):
return float(incorrect) / float(counter) return float(incorrect) / float(counter)
def eer(negatives, positives, is_sorted=False, also_farfrr=False):
"""Calculates the Equal Error Rate (EER).
Please note that it is possible that eer != far != frr.
This function returns (far + frr) / 2 as eer.
If you also need the far and frr values, set ``also_farfrr`` to ``True``.
Parameters
----------
negatives : ``array_like (1D, float)``
The scores for comparisons of objects of different classes.
positives : ``array_like (1D, float)``
The scores for comparisons of objects of the same class.
is_sorted : bool
Are both sets of scores already in ascendantly sorted order?
also_farfrr : bool
If True, it will also return far and frr.
Returns
-------
eer : float
The Equal Error Rate (EER).
far : float
The False Accept Rate (FAR). Returned only when ``also_farfrr`` is
``True``.
frr : float
The False Reject Rate (FAR). Returned only when ``also_farfrr`` is
``True``.
"""
threshold = eer_threshold(negatives, positives, is_sorted)
far, frr = farfrr(negatives, positives, threshold)
if also_farfrr:
return (far + frr) / 2.0, far, frr
return (far + frr) / 2.0
def get_config(): def get_config():
"""Returns a string containing the configuration information. """Returns a string containing the configuration information.
""" """
......
...@@ -23,6 +23,7 @@ Single point measurements ...@@ -23,6 +23,7 @@ Single point measurements
+++++++++++++++++++++++++ +++++++++++++++++++++++++
.. autosummary:: .. autosummary::
bob.measure.eer
bob.measure.farfrr bob.measure.farfrr
bob.measure.f_score bob.measure.f_score
bob.measure.precision_recall bob.measure.precision_recall
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment