Commit 416be191 authored by Theophile GENTILHOMME's avatar Theophile GENTILHOMME
Browse files

Add sort option (sorts return pos/neg scores) in the split function

parent 816862e7
Pipeline #18382 passed with stage
in 33 minutes and 22 seconds
...@@ -289,38 +289,47 @@ def scores(filename, ncolumns=None): ...@@ -289,38 +289,47 @@ def scores(filename, ncolumns=None):
return _iterate_score_file(filename) return _iterate_score_file(filename)
def split(filename, ncolumns=None): def split(filename, ncolumns=None, sort=False):
"""split(filename, ncolumns=None) -> negatives, positives """Loads the scores from the given score file and splits them into positives
and negatives.
Loads the scores from the given score file and splits them into positives and negatives. Depending on the score file format, it calls see
:py:func:`bob.measure.load.split_four_column` and
Depending on the score file format, it calls see :py:func:`split_four_column` :py:func:`bob.measure.load.split_five_column` for details.
and :py:func:`split_five_column` for details.
Parameters
Parameters: ----------
filename: :py:class:`str`, ``file-like``: filename : str
The file object that will be opened with :py:func:`open_file` containing the scores. The path to the score file.
ncolumns : int or ``None``
ncolumns: int or ``None`` If specified to be ``4`` or ``5``, the score file will be assumed to be
If specified to be ``4`` or ``5``, the score file will be assumed to be in the given format. in the given format. If not specified, the score file format will be
If not specified, the score file format will be estimated automatically estimated automatically
sort : :obj:`bool`, optional
Returns: If ``True``, will return sorted negatives and positives
negatives: 1D :py:class:`numpy.ndarray` of type float Returns
This array contains the list of scores, for which the ``claimed_id`` and the ``real_id`` are different (see :py:func:`four_column`) -------
positives: 1D :py:class:`numpy.ndarray` of type float negatives : 1D :py:class:`numpy.ndarray` of type float
This array contains the list of scores, for which the ``claimed_id`` and the ``real_id`` are identical (see :py:func:`four_column`) This array contains the list of scores, for which the ``claimed_id`` and
the ``real_id`` are different (see :py:func:`four_column`)
positives : 1D :py:class:`numpy.ndarray` of type float
This array contains the list of scores, for which the ``claimed_id`` and
the ``real_id`` are identical (see :py:func:`four_column`)
""" """
ncolumns = _estimate_score_file_format(filename, ncolumns) ncolumns = _estimate_score_file_format(filename, ncolumns)
if ncolumns == 4: if ncolumns == 4:
return split_four_column(filename) neg, pos = split_four_column(filename)
else: else:
assert ncolumns == 5 assert ncolumns == 5
return split_five_column(filename) neg, pos = split_five_column(filename)
if sort:
neg.sort()
pos.sort()
return neg, pos
def cmc(filename, ncolumns=None): def cmc(filename, ncolumns=None):
......
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