Opened 16 years ago
Closed 16 years ago
#237 closed defect (fixed)
NCC::predict is incorrect for weights (not equal zero or unity)
Reported by: | Peter | Owned by: | Markus Ringnér |
---|---|---|---|
Priority: | major | Milestone: | yat 0.4 |
Component: | classifier | Version: | trunk |
Keywords: | Cc: |
Description (last modified by )
related to ticket:210
void NCC::predict(const DataLookup2D& input, utility::matrix& prediction) const
The problem occurs in this snippet
for(size_t j=0; j<input.columns();j++) { DataLookup1D in(input,j,false); utility::vector weights(in.size(),0); for(size_t i=0; i<in.size();i++) weights(i)=data->weight(i,j); utility::vector out; predict(in,weights,out); prediction.column(j,out); }
The DataLookup1D in
is lookup into a MatrixLookupWeighted?. When calling in(i)
, MatrixLookupWeighted::operator() is called and returns x*w
for the element in question. On the other, weight is also provided to predict(const DataLookup1D& input, const utility::vector& weights
. This results in that instead of having x
and w
vectors we have vectors x*w
and w
.
Change History (4)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
There function value above is actually called data so the quick fix described should be using data->data(i,j) instead.
comment:4 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
The quickest fix would be to rather than creating the
DataLookup1D
asDataLookup1D in(input,j,false);
to first create autility::vector
, fill it withdata->value(i,j)
, and then create aDataLookup1D
from theutility::vector
.The bad thing about this solution is COPYING. In fact, we would copy each value in the vector twice. First when filling the
utility::vector
, second when calling constructorDataLookup1D(const utility::vector&)
(DataLookup1D holds a pointer to a DataLookup2D that holds a pointer to a utility::matrix. This matrix is copied from the utility::vector.).Next suggestion... well I forgot that one, but another solution would of course be to do a larger redesign. I don't know but perhaps we should change the
Distance
interface. Probably not since it is released... but I wanted to bring up the idea.