This function requires that at least one positive example is provided for each pair -- a property that is assured by these functions.
If **threshold** is set to `None`, the recognition rate is defined as the number of test items, for which the
positive score is greater than or equal to all negative scores, divided by
the number of all test items. If several positive scores for one test item exist, the **highest** score is taken.
If **threshold** assumes one value, the recognition rate is defined as the number of test items, for which the
If **threshold** is given, the recognition rate is defined as the number of test items, for which the
positive score is greater than or equal to all negative scores and the threshold divided by
the number of all test items. If several positive scores for one test item exist, the **highest** score is taken.
**Parameters:**
``cmc_scores`` : CMC scores loaded with one of the functions (:py:func:`bob.measure.load.cmc_four_column` or :py:func:`bob.measure.load.cmc_five_column`)
``threshold`` : Decision threshold. If `None`, the decision threshold will be the **highest** positive score.
A list of tuples, where each tuple contains the ``negative`` and ``positive`` scores for one probe of the database
``threshold`` : Decision threshold. If `None`, the decision threshold will be the **highest** positive score.
``threshold`` : float or ``None``
Decision threshold. If ``None``, the decision threshold will be the **highest** positive score.
**Returns:**
...
...
@@ -177,16 +181,17 @@ def cmc(cmc_scores):
forneg,posincmc_scores:
if((type(pos)!=float)and(len(pos)==0)):
raiseValueError("For the CMC computation at least one positive score is necessary. Please review who you are loading the scores. You must set `load_only_negatives=False` in the :py:func:`bob.measure.load.cmc_four_column` or `:py:func:`bob.measure.load.cmc_five_column` methods.")
raiseValueError("For the CMC computation at least one positive score per pair is necessary.")
# get the maximum positive score for the current probe item
# (usually, there is only one positive score, but just in case...)
# (usually, there is only one positive score, but just in case...)
max_pos=numpy.max(pos)
# count the number of negative scores that are higher than the best positive score
# count the number of negative scores that are higher than the best positive score
This function computes log-scaled values between :math:`10^{M}` and 1 (including), where :math:`M` is the ``min_ste`` argument, which needs to be a negative integer.
The integral ``counts_per_step`` value defines how many values between two adjacent powers of 10 will be created.
The total number of values will be ``-min_step * counts_per_step + 1``.
**Parameters:**
``min_step`` : int (negative)
The power of 10 that will be the minimum value. E.g., the default ``-4`` will result in the first number to be :math:`10^{-4}` = ``0.00001`` or ``0.01%``
``counts_per_step`` : int (positive)
The number of values that will be put between two adjacent powers of 10.
With the default value ``4`` (and default values of ``min_step``), we will get ``log_list[0] == 1e-4``, ``log_list[4] == 1e-3``, ..., ``log_list[16] == 1``.
**Returns**
``log_list`` : [float]
A list of logarithmically scaled values between :math:`10^{M}` and 1.
The values for the FAR, where the CAR should be plotted; each value should be in range [0,1].
``rank`` : int or ``None``
The rank for which the curve should be plotted. If ``None``, rank 1 is assumed.
``logx`` : bool
Plot the FAR axis in logarithmic scale using :py:func:`matplotlib.pyplot.semilogx` or in linear scale using :py:func:`matplotlib.pyplot.plot`? (Default: ``True``)
``kwargs`` : keyword arguments
Extra plotting parameters, which are passed directly to :py:func:`matplotlib.pyplot.plot` or :py:func:`matplotlib.pyplot.semilogx`.
**Returns:**
The return value is the ``matplotlib`` line that was added as defined by :py:func:`matplotlib.pyplot.plot`.
.. [LiJain2005] **Stan Li and Anil K. Jain**, *Handbook of Face Recognition*, Springer, 2005
"""
frommatplotlibimportpyplot
from.importfar_threshold,recognition_rate
# get all negative scores and sort them to compute the FAR thresholds