[R] Manually calculate SVM

Steve Lianoglou mailinglist.honeypot at gmail.com
Fri Mar 26 03:45:24 CET 2010


> 1) I get that the kernel is a "normal function".  But my understanding
> was that the kernel created a higher dimensional space than the original
> data, thus allowing the SVM to be a "pseudo-linear" classifier in that
> higher dimension.

I've been fond of this video that shows "the point":
http://www.youtube.com/watch?v=3liCbRZPrZA

> So, if the the kernel is the dot_product do I iterate
> through all the values of X?  For example  x_i * x_i+1 * x_1+2 etc?

I'm losing you ... it's hard to explain math in english sometimes.
What's X in this case ,and x_i? Is the subscript indexing different
dimensions of one example, or different examples?

You said you wanted "good resources." As I mentioned, Andrew Ng's
stuff (lectures and notes) are quite good. Here are the SVM notes,
check them out:

http://www.stanford.edu/class/cs229/notes/cs229-notes3.pdf

Section 7 talks about kernels.

> 2) I was looking at the SVM tool in the gputools package.  it looks
> great, but only delivers a predicted class {0,1} and I want values.  So
> my thought was to calculate them on my own.  If I have a SV with 10
> elements and a single coefficient for it and am using an RBF kernel, how
> would I put that together in R??

How do you think you would do it?

You can get the formula for the rbf kernel from lots of places, is
translating the formula into R code the problem, or?

If you want to cut straight to the chase, download the source code for
the kernlab package and look through it. The R/kernels.R file has the
rbfdot function.

You can also look at the help for ?kernelMatrix and the corresponding
source code for the function: which lets you build your own kernel
matrix from a custom "kernel function" (which is basically the kernel
function applied to your all-by-all example matrix).

-steve

-- 
Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact



More information about the R-help mailing list