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
ef682da1
Commit
ef682da1
authored
Feb 22, 2019
by
André Anjos
💬
Browse files
Merge branch 'fix_minimizing_threshold' into 'master'
Fix minimizing threshold Closes
#59
See merge request
!92
parents
022f9712
ad5bb33c
Pipeline
#28002
failed with stages
in 4 minutes and 4 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
bob/measure/cpp/error.h
View file @
ef682da1
...
...
@@ -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 @
ef682da1
...
...
@@ -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
+
1e-8
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