Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
2ecf811d
Commit
2ecf811d
authored
Dec 04, 2011
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a minor bug in how the cross validation accuracy was being
computed.
parent
94d7305a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
cross_validate_assignment_trainer.h
dlib/svm/cross_validate_assignment_trainer.h
+21
-5
No files found.
dlib/svm/cross_validate_assignment_trainer.h
View file @
2ecf811d
...
...
@@ -114,13 +114,14 @@ namespace dlib
const
long
num_in_test
=
samples
.
size
()
/
folds
;
const
long
num_in_train
=
samples
.
size
()
-
num_in_test
;
running_stats
<
double
>
rs
;
std
::
vector
<
sample_type
>
samples_test
,
samples_train
;
std
::
vector
<
label_type
>
labels_test
,
labels_train
;
long
next_test_idx
=
0
;
double
total_right
=
0
;
double
total
=
0
;
for
(
long
i
=
0
;
i
<
folds
;
++
i
)
...
...
@@ -148,13 +149,28 @@ namespace dlib
}
rs
.
add
(
test_assignment_function
(
trainer
.
train
(
samples_train
,
labels_train
),
samples_test
,
labels_test
));
const
typename
trainer_type
::
trained_function_type
&
df
=
trainer
.
train
(
samples_train
,
labels_train
);
// check how good df is on the test data
for
(
unsigned
long
i
=
0
;
i
<
samples_test
.
size
();
++
i
)
{
const
std
::
vector
<
long
>&
out
=
df
(
samples_test
[
i
]);
for
(
unsigned
long
j
=
0
;
j
<
out
.
size
();
++
j
)
{
if
(
out
[
j
]
==
labels_test
[
i
][
j
])
++
total_right
;
++
total
;
}
}
}
// for (long i = 0; i < folds; ++i)
return
rs
.
mean
();
if
(
total
!=
0
)
return
total_right
/
total
;
else
return
1
;
}
// ----------------------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
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