On Thu, Aug 16, 2012 at 12:05 AM, Andrei Arsene Simion
<andrei.arsene.simion at gmail.com> wrote:> Hi,
>
> If I do a standard svm regression with e1071
>
> x <- seq(0.1, 5, by = 0.05)
> y <- log(x) + rnorm(x, sd = 0.2)
> m <- svm(x, y)
>
> we can do predict(m,x) to get the fitted values. But what if I wan tho get
them by hand?
>
> Seem to me like it should be
>
> w = t(m$coefs)%*%m$SV
> x.scaled = scale(x, m$x.scale[[1]], m$x.scale[[2]])
> t(w %*% t(as.matrix(x.scaled))) - m$rho but this is wrong
>
> If i get this right what the answer should be is
>
> f(x) = w%*%phi(x)+b but the question is what exactly is phi (by default)
and how do you do this if you cannot get phi in
> closer form (rbf kernel?). It seems like the answer would lie with the dual
representation of the above, i think it is
>
> f(x) = sum_{support vectors}{(a_i-a*^{*}_{i})K(x_{i},x)}+b but how do you
get the a variables everything else. An actual formula would be greatly
appreciated!
I'll do you one better:
getAnywhere(predict.svm)
Though you might need to follow that down into the C code. Look into
the /src/ directory of the package sources (not a binary) available
from CRAN: http://cran.r-project.org/package=e1071
Huzzah for Open Source!
Cheers,
Michael
>
> Thanks!
>
> -Andrei
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.