Commit 8dad77dd authored by Davis King's avatar Davis King

Made the svm_c_ekm_trainer print out the projection error for the margin violators

when in verbose mode.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403672
parent fd932000
...@@ -375,8 +375,8 @@ namespace dlib ...@@ -375,8 +375,8 @@ namespace dlib
if (verbose) if (verbose)
{ {
std::cout << "\nMean EKM projection error: " << rs.mean() << std::endl; std::cout << "\nMean EKM projection error: " << rs.mean() << std::endl;
std::cout << "Standard deviaion of EKM projection error: " << rs.stddev() << std::endl; std::cout << "Standard deviation of EKM projection error: " << rs.stddev() << std::endl;
} }
// now do the training // now do the training
...@@ -546,7 +546,7 @@ namespace dlib ...@@ -546,7 +546,7 @@ namespace dlib
// Reproject all the data samples using the final basis. We could just use what we // Reproject all the data samples using the final basis. We could just use what we
// already have but the recursive thing done above to compute the proj_samples // already have but the recursive thing done above to compute the proj_samples
// might have accumulated a little numerical error. So lets just be safe. // might have accumulated a little numerical error. So lets just be safe.
running_stats<scalar_type> rs; running_stats<scalar_type> rs, rs_margin;
for (long i = 0; i < x.size(); ++i) for (long i = 0; i < x.size(); ++i)
{ {
if (verbose) if (verbose)
...@@ -554,6 +554,9 @@ namespace dlib ...@@ -554,6 +554,9 @@ namespace dlib
scalar_type err; scalar_type err;
proj_samples[i] = ekm.project(x(i),err); proj_samples[i] = ekm.project(x(i),err);
rs.add(err); rs.add(err);
// if this point is within the margin
if (df(proj_samples[i])*y(i) < 1)
rs_margin.add(err);
} }
else else
{ {
...@@ -568,8 +571,11 @@ namespace dlib ...@@ -568,8 +571,11 @@ namespace dlib
if (verbose) if (verbose)
{ {
std::cout << "\nMean EKM projection error: " << rs.mean() << std::endl; std::cout << "\nMean EKM projection error: " << rs.mean() << std::endl;
std::cout << "Standard deviaion of EKM projection error: " << rs.stddev() << std::endl; std::cout << "Standard deviation of EKM projection error: " << rs.stddev() << std::endl;
std::cout << "Mean EKM projection error for margin violators: " << rs_margin.mean() << std::endl;
std::cout << "Standard deviation of EKM projection error for margin violators: " << ((rs_margin.current_n()>1)?rs_margin.stddev():0) << std::endl;
std::cout << "Final svm objective: " << svm_objective << std::endl; std::cout << "Final svm objective: " << svm_objective << std::endl;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment