Opened 14 years ago

Closed 14 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 Peter)

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++) 
				utility::vector 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 14 years ago by Peter

The quickest fix would be to rather than creating the DataLookup1D as DataLookup1D in(input,j,false); to first create a utility::vector, fill it with data->value(i,j), and then create a DataLookup1D from the utility::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 constructor DataLookup1D(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.

comment:2 Changed 14 years ago by Markus Ringnér

There function value above is actually called data so the quick fix described should be using data->data(i,j) instead.

comment:3 Changed 14 years ago by Peter

Description: modified (diff)


Also have a look at ticket:210

comment:4 Changed 14 years ago by Markus Ringnér

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.