16.5 SVM Predict


tbischel
04-18-2009, 09:01 AM
Hi, I'm having trouble understanding how the predict function is supposed to work on page 897... here we see the line,

for(int j=0; j<m; j++)
sum += alph[j]*gker.y[j]*(gker.kernel(j,x)+1.0);

the call to the kernel specifies that two arrays of doubles should be passed, but this line passes j as an integer, and x as an array of doubles. What am I missing?

davekw7x
04-18-2009, 04:07 PM
...trouble understanding...


The expression that you are questioning is

Doub predict(Doub *x)
{
... for (Int j = ...SomeOtherStuff)...
SomeOtherStuff...gker.kernel(j,x)...SomeOtherStuff
...
}

Where gker is a reference to an Svmgkernel struct.

...the call to the kernel specifies that two arrays of doubles should be passed
Actually, in the definition of Svmgenkernel struct there are two different kernel() functions. One of them takes two pointers to Doub, and the other is defined with an Int as the first parameter and a pointer to Doub as the second parameter.

In this expression, j is an Int, and x is a pointer to Doub, so it parses correctly, and that particular part of the expression is a Doub that has the value returned by the second kernel() function.

Now, once we get past the C++ part of the problem, understanding how the predict() function actually works is another matter, but I hope that this gets us over this little speedbump.


Regards,

Dave

tbischel
04-18-2009, 04:25 PM
Thanks a bunch, Overlooked that!
--Tyler