Skip to content
GitLab
Menu
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
f67d3a34
Commit
f67d3a34
authored
Nov 16, 2017
by
Amir MOHAMMADI
Browse files
Compute roc using roc_for_far internally
parent
4281a0c2
Pipeline
#14105
passed with stages
in 16 minutes and 40 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/measure/cpp/error.cpp
View file @
f67d3a34
...
...
@@ -214,18 +214,15 @@ double bob::measure::minWeightedErrorRateThreshold(
blitz
::
Array
<
double
,
2
>
bob
::
measure
::
roc
(
const
blitz
::
Array
<
double
,
1
>
&
negatives
,
const
blitz
::
Array
<
double
,
1
>
&
positives
,
size_t
points
)
{
double
min
=
std
::
min
(
blitz
::
min
(
negatives
),
blitz
::
min
(
positives
));
double
max
=
std
::
max
(
blitz
::
max
(
negatives
),
blitz
::
max
(
positives
));
double
step
=
(
max
-
min
)
/
((
double
)
points
-
1.0
);
blitz
::
Array
<
double
,
2
>
retval
(
2
,
points
);
for
(
int
i
=
0
;
i
<
(
int
)
points
;
++
i
)
{
std
::
pair
<
double
,
double
>
ratios
=
bob
::
measure
::
farfrr
(
negatives
,
positives
,
min
+
i
*
step
);
// preserve X x Y ordering (FAR x FRR)
retval
(
0
,
i
)
=
ratios
.
first
;
retval
(
1
,
i
)
=
ratios
.
second
;
// Uses roc_for_far internally
// Create an far_list
blitz
::
Array
<
double
,
1
>
far_list
((
int
)
points
);
int
min_far
=
-
8
;
// minimum FAR in terms of 10^(min_far)
double
counts_per_step
=
points
/
(
-
min_far
)
;
for
(
int
i
=
1
-
(
int
)
points
;
i
<=
0
;
++
i
)
{
far_list
(
i
+
(
int
)
points
-
1
)
=
std
::
pow
(
10.
,
(
double
)
i
/
counts_per_step
);
}
return
retval
;
return
bob
::
measure
::
roc_for_far
(
negatives
,
positives
,
far_list
,
false
)
;
}
blitz
::
Array
<
double
,
2
>
...
...
@@ -445,9 +442,9 @@ bob::measure::roc_for_far(const blitz::Array<double, 1> &negatives,
if
(
far_index
>=
0
)
{
// walk to the end of both lists; at least one of both lists should already
// have reached its limit.
while
(
pos_it
++
!=
pos
.
end
())
while
(
pos_it
!=
pos
.
end
()
&&
pos_it
++
!=
pos
.
end
())
++
pos_index
;
while
(
neg_it
++
!=
neg
.
end
())
while
(
neg_it
!=
neg
.
end
()
&&
neg_it
++
!=
neg
.
end
())
++
neg_index
;
// fill in the remaining elements of the CAR list
do
{
...
...
bob/measure/data/nonsep-det.hdf5
View file @
f67d3a34
No preview for this file type
bob/measure/data/nonsep-roc.hdf5
View file @
f67d3a34
No preview for this file type
bob/measure/test_error.py
View file @
f67d3a34
...
...
@@ -251,7 +251,7 @@ def test_plots():
# This example will test the ROC plot calculation functionality.
xy
=
roc
(
negatives
,
positives
,
100
)
# uncomment the next line to save a reference value
# save('nonsep-roc.hdf5', xy)
# save(
F(
'nonsep-roc.hdf5'
)
, xy)
xyref
=
bob
.
io
.
base
.
load
(
F
(
'nonsep-roc.hdf5'
))
assert
numpy
.
array_equal
(
xy
,
xyref
)
...
...
@@ -273,7 +273,7 @@ def test_plots():
# This example will test the DET plot calculation functionality.
det_xyzw
=
det
(
negatives
,
positives
,
100
)
# uncomment the next line to save a reference value
# save('nonsep-det.hdf5', det_xyzw)
# save(
F(
'nonsep-det.hdf5'
)
, det_xyzw)
det_xyzw_ref
=
bob
.
io
.
base
.
load
(
F
(
'nonsep-det.hdf5'
))
assert
numpy
.
allclose
(
det_xyzw
,
det_xyzw_ref
,
atol
=
1e-15
)
...
...
Write
Preview
Supports
Markdown
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