[R] Re: Writing new kernel option in svm E1071

David Meyer david.meyer at ci.tuwien.ac.at
Mon Jul 8 12:00:15 CEST 2002


Dear Adai,

unfortunately, you currently can't extend the kernel set at the R level
(and due to performance issues this probably will never be possible).

(It's quite simple at the C-level, though).

But I think an option for providing the computed kernel values would be
a useful feature easy to add; I cc: this mail to Chih-Jen Lin, the
author of LIBSVM, perhaps he agrees.

g.,
-d



> Adaikalavan Ramasamy wrote:
> 
> I am trying to use the svm function in E1071 package. It does come
> with built in kernel functions like radial, linear etc. I wish to use
> the radial basis function but with a constant added to the diagonal of
> the kernel (or Gram) matrix. This was the suggested method in a paper
> UCSC-CRL-99-09 Brown et al.
> 
> So I wrote the following code, [which works correctly if I test on two
> vectors manually]
> 
> kernel.new.fn <- function(u,v)
> {   exp(-gamma*det(t(u-v)%*%(u-v), method="qr")) +
> ifelse(identical(u, v), 0.1 ,0)    }
> 
> But when I try to run the code, I get the following error:
> 
> > test.svm  <- svm( X ,  Ysvm, kernel="kernel.new.fn")
> Error in svm.default(X.complete, Ysvm[, 3], kernel = "kernel.new.fn")
> :
>  wrong kernel specification!
> 
> I am guessing the problem being svm.default does not recognise
> "kernel.new.fn".
> svm.default calls a C file "svmtrain" to do the calculations.
> 
> Q1: Is there an exisiting option to add a constant to the diagonal of
> the kernel ?

no.

> Q2: Is there a way I can get svm.default to recognise there is new
> option called kernel.new.fn externally without meddling with C
> file which I am not so familiar with.

no.

>        [OR equivalently is there a way of feeding in the
> computed kernel instead - I can do this manually using a loop]

again, no.

> 
> This is as much due to my lack of programming as it is to my lack of
> experience with svm.
> 
> Many thanks in advance, Adai.
> 
> 
> 
> 
> 
> 

-- 
	Mag. David Meyer		Wiedner Hauptstrasse 8-10
Vienna University of Technology		A-1040 Vienna/AUSTRIA
         Department of			Tel.: (+431) 58801/10772
Statistics and Probability Theory	mail: david.meyer at ci.tuwien.ac.at
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list