Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.measure
Commits
ae3b20c1
Commit
ae3b20c1
authored
Oct 16, 2015
by
Manuel Günther
Browse files
Handled cases for CMC, where no scores are provided
parent
b4a40ba8
Changes
1
Hide whitespace changes
Inline
Side-by-side
bob/measure/__init__.py
View file @
ae3b20c1
...
...
@@ -87,6 +87,10 @@ def recognition_rate(cmc_scores):
the number of all test items. If several positive scores for one test item
exist, the **highest** score is taken.
"""
# If no scores are given, the recognition rate is exactly 0.
if
not
cmc_scores
:
return
0
correct
=
0.
for
neg
,
pos
in
cmc_scores
:
# get the maximum positive score for the current probe item
...
...
@@ -96,7 +100,7 @@ def recognition_rate(cmc_scores):
if
(
neg
<
max_pos
).
all
():
correct
+=
1
# return relative number of
# return relative number of
correctly matched scores
return
correct
/
float
(
len
(
cmc_scores
))
def
cmc
(
cmc_scores
):
...
...
@@ -115,6 +119,11 @@ def cmc(cmc_scores):
many test items have rank r or higher.
"""
# If no scores are given, we cannot plot anything
probe_count
=
float
(
len
(
cmc_scores
))
if
not
probe_count
:
raise
ValueError
(
"The given set of scores is empty"
)
# compute MC
match_characteristic
=
numpy
.
zeros
((
max
([
len
(
neg
)
for
(
neg
,
pos
)
in
cmc_scores
])
+
1
,),
numpy
.
int
)
for
neg
,
pos
in
cmc_scores
:
...
...
@@ -126,7 +135,6 @@ def cmc(cmc_scores):
match_characteristic
[
index
]
+=
1
# cumulate
probe_count
=
float
(
len
(
cmc_scores
))
cumulative_match_characteristic
=
numpy
.
ndarray
(
match_characteristic
.
shape
,
numpy
.
float64
)
count
=
0.
for
i
in
range
(
match_characteristic
.
shape
[
0
]):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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