Added the ability to get the score in addition to the label out of the

multiclass_linear_decision_function.
This commit is contained in:
Davis King 2013-10-04 22:35:30 -04:00
parent 10dec05a84
commit d6f0fd3743
2 changed files with 27 additions and 2 deletions

View File

@ -778,7 +778,7 @@ namespace dlib
unsigned long number_of_classes (
) const { return labels.size(); }
result_type operator() (
std::pair<result_type, scalar_type> predict (
const sample_type& x
) const
{
@ -798,7 +798,14 @@ namespace dlib
}
}
return labels[best_idx];
return std::make_pair(labels[best_idx], best_val);
}
result_type operator() (
const sample_type& x
) const
{
return predict(x).first;
}
};

View File

@ -927,6 +927,23 @@ namespace dlib
this object)
!*/
std::pair<result_type, scalar_type> predict (
const sample_type& x
) const;
/*!
requires
- weights.size() > 0
- weights.nr() == number_of_classes() == b.size()
- if (x is a dense vector, i.e. a dlib::matrix) then
- is_vector(x) == true
- x.size() == weights.nc()
(i.e. it must be legal to multiply weights with x)
ensures
- Returns the predicted label for the x sample and also it's score.
In particular, it returns the following:
std::make_pair(labels[index_of_max(weights*x-b)], max(weights*x-b))
!*/
result_type operator() (
const sample_type& x
) const;
@ -942,6 +959,7 @@ namespace dlib
- Returns the predicted label for the x sample. In particular, it returns
the following:
labels[index_of_max(weights*x-b)]
Or in other words, this function returns predict(x).first
!*/
};