From ee3a8692bf26a1317e6fb90483ea5be402959648 Mon Sep 17 00:00:00 2001 From: Davis King Date: Fri, 23 Nov 2012 15:44:57 -0500 Subject: [PATCH] Added another overload of test_ranking_function() that takes a single ranking_pair. Also improved wording of comment in svm_rank_trainer_abstract.h --- dlib/svm/ranking_tools.h | 14 ++++++++++++++ dlib/svm/ranking_tools_abstract.h | 22 ++++++++++++++++++++++ dlib/svm/svm_rank_trainer_abstract.h | 6 +++--- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/dlib/svm/ranking_tools.h b/dlib/svm/ranking_tools.h index 6aa344c70..da06004f4 100644 --- a/dlib/svm/ranking_tools.h +++ b/dlib/svm/ranking_tools.h @@ -243,6 +243,20 @@ namespace dlib return static_cast(total_pairs - total_wrong) / total_pairs; } +// ---------------------------------------------------------------------------------------- + + template < + typename ranking_function, + typename T + > + double test_ranking_function ( + const ranking_function& funct, + const ranking_pair& sample + ) + { + return test_ranking_function(funct, std::vector >(1,sample)); + } + // ---------------------------------------------------------------------------------------- template < diff --git a/dlib/svm/ranking_tools_abstract.h b/dlib/svm/ranking_tools_abstract.h index 77d5e267f..370ade85e 100644 --- a/dlib/svm/ranking_tools_abstract.h +++ b/dlib/svm/ranking_tools_abstract.h @@ -178,6 +178,28 @@ namespace dlib (for all valid i,j,k) !*/ +// ---------------------------------------------------------------------------------------- + + template < + typename ranking_function, + typename T + > + double test_ranking_function ( + const ranking_function& funct, + const ranking_pair& sample + ); + /*! + requires + - is_ranking_problem(std::vector >(1, sample)) == true + - ranking_function == some kind of decision function object (e.g. decision_function) + ensures + - This is just a convenience routine for calling the above + test_ranking_function() routine. That is, it just copies sample into a + std::vector object and invokes the above test_ranking_function() routine. + This means that calling this function is equivalent to invoking: + return test_ranking_function(funct, std::vector >(1, sample)); + !*/ + // ---------------------------------------------------------------------------------------- template < diff --git a/dlib/svm/svm_rank_trainer_abstract.h b/dlib/svm/svm_rank_trainer_abstract.h index 8921dd376..22617ffff 100644 --- a/dlib/svm/svm_rank_trainer_abstract.h +++ b/dlib/svm/svm_rank_trainer_abstract.h @@ -218,9 +218,9 @@ namespace dlib - is_ranking_problem(std::vector >(1, sample)) == true ensures - This is just a convenience routine for calling the above train() - function. That is, it just copies sample into an appropriate std::vector - object and invokes the above train() method. That is, this function is - equivalent to invoking: + function. That is, it just copies sample into a std::vector object and + invokes the above train() method. This means that calling this function + is equivalent to invoking: return train(std::vector >(1, sample)); !*/