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
0626adb8
Commit
0626adb8
authored
Feb 21, 2019
by
Saeed SARFJOO
Browse files
fix returned threshold in minimizingThreshold
parent
022f9712
Pipeline
#27378
failed with stage
in 10 minutes and 23 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/measure/cpp/error.h
View file @
0626adb8
...
...
@@ -211,6 +211,7 @@ double minimizingThreshold(const blitz::Array<double, 1> &negatives,
else
current_threshold
+=
*
pos_it
;
current_threshold
/=
2
;
}
}
// while
...
...
@@ -222,6 +223,22 @@ double minimizingThreshold(const blitz::Array<double, 1> &negatives,
min_threshold
=
current_threshold
;
}
// now we just double check choosing the threshold higher than all scores will not improve the min_predicate
if
(
neg_it
!=
negatives
.
end
()
||
pos_it
!=
positives
.
end
())
{
double
last_threshold
=
current_threshold
;
if
(
neg_it
!=
negatives
.
end
())
last_threshold
=
std
::
nextafter
(
negatives
(
negatives
.
extent
(
0
)
-
1
),
negatives
(
negatives
.
extent
(
0
)
-
1
)
+
1
);
else
{
if
(
pos_it
!=
positives
.
end
())
last_threshold
=
std
::
nextafter
(
positives
(
positives
.
extent
(
0
)
-
1
),
positives
(
positives
.
extent
(
0
)
-
1
)
+
1
);
}
current_predicate
=
predicate
(
0.
,
1.
);
if
(
current_predicate
<
min_predicate
)
{
min_predicate
=
current_predicate
;
min_threshold
=
last_threshold
;
}
}
// return the best threshold found
return
min_threshold
;
}
...
...
bob/measure/test_error.py
View file @
0626adb8
...
...
@@ -489,3 +489,18 @@ def test_open_set_rates():
assert
abs
(
bob
.
measure
.
recognition_rate
(
cmc_scores
)
-
6.
/
9.
)
<
1e-8
assert
abs
(
bob
.
measure
.
recognition_rate
(
cmc_scores
,
threshold
=
0.5
)
-
6.
/
8.
)
<
1e-8
def
test_mindcf
():
""" Test outlier scores in negative set
"""
from
bob.measure
import
min_weighted_error_rate_threshold
,
farfrr
cost
=
0.99
negatives
=
[
-
3
,
-
2
,
-
1
,
-
0.5
,
4
]
positives
=
[
0.5
,
3
]
th
=
min_weighted_error_rate_threshold
(
negatives
,
positives
,
cost
,
True
)
far
,
frr
=
farfrr
(
negatives
,
positives
,
th
)
mindcf
=
(
cost
*
far
+
(
1
-
cost
)
*
frr
)
*
100
assert
mindcf
<=
1.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