Commit 8901e32c authored by Davis King's avatar Davis King

Changed the definition of the is_binary_classification_problem() function

so that it is a little more reasonable and also easier to understand.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%403042
parent 9de84b63
......@@ -103,6 +103,8 @@ namespace dlib
const U& x_labels
)
{
bool seen_neg_class = false;
bool seen_pos_class = false;
if (x.nc() != 1 || x_labels.nc() != 1) return false;
if (x.nr() != x_labels.nr()) return false;
if (x.nr() <= 1) return false;
......@@ -110,9 +112,14 @@ namespace dlib
{
if (x_labels(r) != -1 && x_labels(r) != 1)
return false;
if (x_labels(r) == 1)
seen_pos_class = true;
if (x_labels(r) == -1)
seen_neg_class = true;
}
return true;
return seen_pos_class && seen_neg_class;
}
template <
......
......@@ -73,10 +73,12 @@ namespace dlib
- U == a matrix or something convertible to a matrix via vector_to_matrix()
ensures
- returns true if all of the following are true and false otherwise:
- x.nc() == 1 (i.e. x is a column vector)
- x_labels.nc() == 1 (i.e. x_labels is a column vector)
- x.nr() == x_labels.nr()
- x.nr() > 1
- is_col_vector(x) == true
- is_col_vector(x_labels) == true
- x.size() == x_labels.size()
- x.size() > 1
- there exists at least one sample from both the +1 and -1 classes.
(i.e. all samples can't have the same label)
- for all valid i:
- x_labels(i) == -1 or +1
!*/
......
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