Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
bob.measure
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bob
bob.measure
Commits
fb8f306c
Commit
fb8f306c
authored
Oct 28, 2016
by
Manuel Günther
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also provide generic function for cmc scores
parent
18ecfb37
Pipeline
#5145
passed with stages
in 5 minutes and 56 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
36 deletions
+19
-36
bob/measure/load.py
bob/measure/load.py
+19
-36
No files found.
bob/measure/load.py
View file @
fb8f306c
...
...
@@ -159,22 +159,8 @@ def cmc_four_column(filename):
"""
# extract positives and negatives
pos_dict
=
{}
neg_dict
=
{}
# read four column list
for
(
client_id
,
probe_id
,
probe_name
,
score
)
in
four_column
(
filename
):
# check in which dict we have to put the score
correct_dict
=
pos_dict
if
client_id
==
probe_id
else
neg_dict
# append score
if
probe_name
in
correct_dict
:
correct_dict
[
probe_name
].
append
(
score
)
else
:
correct_dict
[
probe_name
]
=
[
score
]
# convert that into the desired format
return
_convert_cmc_scores
(
neg_dict
,
pos_dict
)
score_lines
=
four_column
(
filename
)
return
_split_cmc_scores
(
score_lines
,
1
)
def
five_column
(
filename
):
...
...
@@ -274,22 +260,9 @@ def cmc_five_column(filename):
``positive`` scores for one probe of the database.
"""
# extract positives and negatives
pos_dict
=
{}
neg_dict
=
{}
# read four column list
for
(
client_id
,
_
,
probe_id
,
probe_name
,
score
)
in
five_column
(
filename
):
# check in which dict we have to put the score
correct_dict
=
pos_dict
if
client_id
==
probe_id
else
neg_dict
# append score
if
probe_name
in
correct_dict
:
correct_dict
[
probe_name
].
append
(
score
)
else
:
correct_dict
[
probe_name
]
=
[
score
]
score_lines
=
four_column
(
filename
)
return
_split_cmc_scores
(
score_lines
,
2
)
# convert that into the desired format
return
_convert_cmc_scores
(
neg_dict
,
pos_dict
)
def
load_score
(
filename
,
ncolumns
=
None
):
...
...
@@ -431,12 +404,22 @@ def _split_scores(score_lines, real_id_index, claimed_id_index = 0, score_index
return
(
numpy
.
array
(
negatives
),
numpy
.
array
(
positives
))
def
_convert_cmc_scores
(
neg_dict
,
pos_dict
):
"""Converts the negative and positive scores read with
:py:func:`cmc_four_column` or :py:func:`cmc_four_column` into a format that
is handled by the :py:func:`bob.measure.cmc` and similar functions.
def
_split_cmc_scores
(
score_lines
,
real_id_index
,
probe_name_index
=
None
,
claimed_id_index
=
0
,
score_index
=
-
1
):
"""Takes the output of :py:func:`four_column` or :py:func:`five_column` and return cmc scores.
"""
if
probe_name_index
is
None
:
probe_name_index
=
real_id_index
+
1
# extract positives and negatives
pos_dict
=
{}
neg_dict
=
{}
# read four column list
for
line
in
score_lines
:
which
=
pos_dict
if
line
[
claimed_id_index
]
==
line
[
real_id_index
]
else
neg_dict
probe_name
=
line
[
probe_name_index
]
# append score
if
probe_name
not
in
which
:
which
[
probe_name
]
=
[]
which
[
probe_name
].
append
(
line
[
score_index
])
# convert to lists of tuples of ndarrays (or None)
probe_names
=
sorted
(
set
(
neg_dict
.
keys
()).
union
(
set
(
pos_dict
.
keys
())))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment