[R] kernlab and gram matrix

Andreas Maunz andreas at maunz.de
Mon Dec 17 09:42:14 CET 2007


Hi, this is a question about the R package kernlab.

I use kernlab as a library in a C++ program. The host application 
defines a graph kernel (defined by me), generates a gram matrix and 
trains kernlab directly on this gram matrix, like this:

regm<-ksvm(K,y,kernel="matrix"),

where K is the n x n gram kernelMatrix of my kernel, and y is the 
R-vector of quantitative target values.
So, to make sure you got it: I don't want kernlab to compute the kernel 
values by itself. Rather, this is a task for the host application.

Learning (see above) works well, but how do I predict a new instance? I 
couldn't find any information in this respect in the manual. The only 
examples for prediction were concerned with data from the input space, 
which i don't have, since my input space consists of graphs. I tried the 
following:

predict(regm,x,type="response")

where x is the 1xn R-matrix containing kernel values between the 
instance to be predicted and my training points. This won't work:

Error in as.matrix(Z) : object "Z" not found.

I'm using the current CRAN version of kernlab. Any help by kernlab users 
who had a similar task to do would be appreciated.

Best regards,
Andreas Maunz
-- 
http://www.maunz.de

       Yoda of Borg are we: Futile is resistance. Assimilate you, we will.



More information about the R-help mailing list