Commit 841966b0 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Bug Fix:

Classification should not try to classify class -1.0
parent 7274879b
......@@ -29,7 +29,8 @@ ConvexHull1D::ConvexHull1D() :
_cls_start(),
_cls_sz(),
_n_task(0),
_n_class(0)
_n_class(0),
_exclude_cl_ind(-1)
{}
ConvexHull1D::ConvexHull1D(std::vector<int> task_sizes, const double* prop) :
......@@ -40,7 +41,8 @@ ConvexHull1D::ConvexHull1D(std::vector<int> task_sizes, const double* prop) :
_cls_start(),
_cls_sz(),
_n_task(task_sizes.size()),
_n_class(0)
_n_class(0),
_exclude_cl_ind(-1)
{
initialize_prop(task_sizes, prop);
}
......@@ -85,8 +87,12 @@ void ConvexHull1D::initialize_prop(std::vector<int> task_sizes, const double* pr
cl_ind[unique_prop_vals[cc]] = cc;
}
int start = 0;
if(cl_ind.count(-1.0) > 0)
{
_exclude_cl_ind = cl_ind[-1.0];
}
int start = 0;
for(int tt = 0; tt < task_sizes.size(); ++tt)
{
util_funcs::argsort<double>(
......@@ -105,6 +111,11 @@ void ConvexHull1D::initialize_prop(std::vector<int> task_sizes, const double* pr
_cls_start[tt * _n_class + cc] = start;
start += _cls_sz[tt * _n_class + cc];
}
if(_exclude_cl_ind >= 0)
{
_cls_sz[tt * _n_class + _exclude_cl_ind] = 0;
}
}
}
......@@ -136,8 +147,8 @@ double ConvexHull1D::overlap_1d(double* value, double width)
for(int tt = 0; tt < _n_task; ++tt)
{
double cls_norm = 1.0 / (
static_cast<double>(_n_class) *
static_cast<double>(_n_class - 1) *
static_cast<double>(_n_class - (_exclude_cl_ind >= 0)) *
static_cast<double>(_n_class - (_exclude_cl_ind >= 0) - 1) *
static_cast<double>(_n_task)
);
for(int c1 = 0; c1 < _n_class; ++c1)
......
......@@ -46,6 +46,7 @@ protected :
int _n_class; //!< Number of classes
int _n_task; //!< Number of tasks
int _exclude_cl_ind; //!< Ind corresponding to a class number of -1.0
public:
/**
......
......@@ -167,7 +167,6 @@ double LossFunctionConvexHull::project(const node_ptr& feat)
{
_scores[pp] = _convex_hull[pp].overlap_1d(val_ptr);
}
return *std::min_element(_scores.begin(), _scores.end());
}
......
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