[R] ksvm and predict

Juan cj11m at hotmail.com
Tue Sep 20 19:50:01 CEST 2011


Hello,

I am using the kernlab package to do regression.
I have a data frame called Data6 which looks like this:

head(Data6)

        WA       PO       ZA       ZB       ZC       ZD      KL
1 2.955447 6.378324 14.10622 0.134343 0.247120 0.734810 4.05988
2 2.939718 6.344122 14.03528 0.127512 0.000000 0.955253 4.02952
3 2.907939 6.254080 13.89342 0.111573 0.247120 3.674050 3.99476
4 2.884506 6.221972 13.82095 0.052371 0.000000 3.600569 3.95384
5 2.880333 6.257570 13.85795 0.031878 0.160628 0.587848 3.96000
6 2.897667 6.285490 14.01370 0.138897 0.049424 1.616582 4.00048

up to 999 rows of data.

I wrote the following function

train.KL <- ksvm(KL~., data=Data6, C=100,
epsilon=0.001,kpar="automatic",cross=10)
pred.KL<-predict(train.KL,WA)

pred.KL
4.0599
4.0302
3.9949
3.9545
3.9604
4.0004
3.9607

Now, suppose I have a new data for WA=2.8488. If I write:

predict(train.KL,2.8488)

I get a matrix with 1 column and 999 rows while I expected to have a single
value.

Could anyone tell me what I am doing wrong?

I don´t even know if I am using the ksvm and the predict funtions
correctrly, since I
wrote the ksvm fuction to model a parameter as a funtion of all the remaning
columns
(I did it because I get better results that if I use just WA) but I whant to
make a
prediction of KL using just the first of them (WA). Any suggestions?

Thanks a lot for your help.

Regards,

Juan

--
View this message in context: http://r.789695.n4.nabble.com/ksvm-and-predict-tp3827634p3827634.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list