Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.measure
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.measure
Commits
ac3d216a
There was a problem fetching the pipeline summary.
Commit
ac3d216a
authored
7 years ago
by
Amir MOHAMMADI
Browse files
Options
Downloads
Patches
Plain Diff
recompute far values in roc_for_far
parent
4bf48e9b
No related branches found
No related tags found
1 merge request
!48
recompute far values in roc_for_far
Pipeline
#
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/measure/cpp/error.cpp
+11
-63
11 additions, 63 deletions
bob/measure/cpp/error.cpp
with
11 additions
and
63 deletions
bob/measure/cpp/error.cpp
+
11
−
63
View file @
ac3d216a
...
@@ -421,73 +421,21 @@ bob::measure::roc_for_far(const blitz::Array<double, 1> &negatives,
...
@@ -421,73 +421,21 @@ bob::measure::roc_for_far(const blitz::Array<double, 1> &negatives,
sort
(
negatives
,
neg
,
is_sorted
);
sort
(
negatives
,
neg
,
is_sorted
);
sort
(
positives
,
pos
,
is_sorted
);
sort
(
positives
,
pos
,
is_sorted
);
// do some magic to compute the FRR list
blitz
::
Array
<
double
,
2
>
retval
(
2
,
n_points
);
blitz
::
Array
<
double
,
2
>
retval
(
2
,
n_points
);
// index into the FAR
and FRR
list
// index into the FAR list
int
far_index
=
n_points
-
1
;
int
far_index
=
n_points
-
1
;
int
pos_index
=
0
,
neg_index
=
0
;
int
n_pos
=
pos
.
extent
(
0
),
n_neg
=
neg
.
extent
(
0
);
// iterators into the result lists
auto
pos_it
=
pos
.
begin
(),
neg_it
=
neg
.
begin
();
// do some fast magic to compute the FRR values ;-)
do
{
// check whether the current positive value is less than the current
// negative one
if
(
*
pos_it
<
*
neg_it
)
{
// increase the positive count
++
pos_index
;
// go to the next positive value
++
pos_it
;
}
else
{
// increase the negative count
++
neg_index
;
// go to the next negative value
++
neg_it
;
}
// check, if we have reached a new FAR limit,
// i.e. if the relative number of negative similarities is greater than
// 1-FAR (which is the CRR)
if
(((
double
)
neg_index
/
(
double
)
n_neg
>
1.
-
far_list
(
far_index
))
&&
!
(
bob
::
core
::
isClose
((
double
)
neg_index
/
(
double
)
n_neg
,
1.
-
far_list
(
far_index
),
1e-9
,
1e-9
)))
{
// copy the far value
retval
(
0
,
far_index
)
=
far_list
(
far_index
);
// calculate the FRR for the current FAR
retval
(
1
,
far_index
)
=
(
double
)
pos_index
/
(
double
)
n_pos
;
// go to the next FAR value
--
far_index
;
}
// do this, as long as there are elements in both lists left and not all FRR
// Get the threshold for the requested far values and calculate far and frr
// elements where calculated yet
// values based on the threshold.
}
while
(
pos_it
!=
pos
.
end
()
&&
neg_it
!=
neg
.
end
()
&&
far_index
>=
0
);
while
(
far_index
>=
0
)
{
// calculate the threshold for the requested far
// check if all FRR values have been set
auto
threshold
=
bob
::
measure
::
farThreshold
(
neg
,
pos
,
far_list
(
far_index
),
true
);
if
(
far_index
>=
0
)
{
// calculate the frr and re-calculate the far
// walk to the end of both lists; at least one of both lists should already
auto
farfrr
=
bob
::
measure
::
farfrr
(
neg
,
pos
,
threshold
);
// have reached its limit.
retval
(
0
,
far_index
)
=
farfrr
.
first
;
while
(
pos_it
!=
pos
.
end
()
&&
pos_it
++
!=
pos
.
end
())
retval
(
1
,
far_index
)
=
farfrr
.
second
;
++
pos_index
;
far_index
--
;
while
(
neg_it
!=
neg
.
end
()
&&
neg_it
++
!=
neg
.
end
())
++
neg_index
;
// fill in the remaining elements of the CAR list
do
{
// copy the FAR value
retval
(
0
,
far_index
)
=
far_list
(
far_index
);
// check if the criterion is fulfilled (should be, as long as the lowest
// far is not below 0)
if
((
double
)
neg_index
/
(
double
)
n_neg
>
1.
-
far_list
(
far_index
))
{
// calculate the FRR for the current FAR
retval
(
1
,
far_index
)
=
(
double
)
pos_index
/
(
double
)
n_pos
;
}
else
{
// set FRR to 1 (this should never happen, but might be due to numerical
// issues)
retval
(
1
,
far_index
)
=
1.
;
}
}
while
(
far_index
--
);
}
}
return
retval
;
return
retval
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment