Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
2ecf811d
Commit
2ecf811d
authored
Dec 03, 2011
by
Davis King
Browse files
Fixed a minor bug in how the cross validation accuracy was being
computed.
parent
94d7305a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
5 deletions
+21
-5
dlib/svm/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
...
@@ -114,13 +114,14 @@ namespace dlib
const
long
num_in_test
=
samples
.
size
()
/
folds
;
const
long
num_in_test
=
samples
.
size
()
/
folds
;
const
long
num_in_train
=
samples
.
size
()
-
num_in_test
;
const
long
num_in_train
=
samples
.
size
()
-
num_in_test
;
running_stats
<
double
>
rs
;
std
::
vector
<
sample_type
>
samples_test
,
samples_train
;
std
::
vector
<
sample_type
>
samples_test
,
samples_train
;
std
::
vector
<
label_type
>
labels_test
,
labels_train
;
std
::
vector
<
label_type
>
labels_test
,
labels_train
;
long
next_test_idx
=
0
;
long
next_test_idx
=
0
;
double
total_right
=
0
;
double
total
=
0
;
for
(
long
i
=
0
;
i
<
folds
;
++
i
)
for
(
long
i
=
0
;
i
<
folds
;
++
i
)
...
@@ -148,13 +149,28 @@ namespace dlib
...
@@ -148,13 +149,28 @@ namespace dlib
}
}
rs
.
add
(
test_assignment_function
(
trainer
.
train
(
samples_train
,
labels_train
),
const
typename
trainer_type
::
trained_function_type
&
df
=
trainer
.
train
(
samples_train
,
labels_train
);
samples_test
,
labels_test
));
// 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)
}
// 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