LFD Book Forum

LFD Book Forum (http://book.caltech.edu/bookforum/index.php)
-   The Final (http://book.caltech.edu/bookforum/forumdisplay.php?f=138)
-   -   Q13 bizarre results (http://book.caltech.edu/bookforum/showthread.php?t=4341)

Steph 06-10-2013 09:13 AM

Q13 bizarre results
 
Hi,

Just wondering if anyone has encountered what I'm seeing, or if (more likely) I'm doing something stupid...

I'm using the svm command in the e1071 package in R to implement hard margin SVM. Working on Q14, Ein is often not 0, but most of the time when Ein > 0, I actually get Ein = 100. That is, the data set is linearly separable in the Z space, but for some reason the response values are exactly flipped.

This seems bizarre to me, yet I can't figure out why it might be happening. I'm wondering if I'm not correctly implementing the constant "b". I simply added a column of ones to my x matrix and moved forward with svm.

Any thoughts would be much appreciated.

Thanks,
Steph

jforbes 06-10-2013 01:32 PM

Re: Q14 bizarre results
 
Quote:

Originally Posted by Steph (Post 11078)
Hi,

Just wondering if anyone has encountered what I'm seeing, or if (more likely) I'm doing something stupid...

I'm using the svm command in the e1071 package in R to implement hard margin SVM. Working on Q14, Ein is often not 0, but most of the time when Ein > 0, I actually get Ein = 100. That is, the data set is linearly separable in the Z space, but for some reason the response values are exactly flipped.

This seems bizarre to me, yet I can't figure out why it might be happening. I'm wondering if I'm not correctly implementing the constant "b". I simply added a column of ones to my x matrix and moved forward with svm.

Any thoughts would be much appreciated.

Thanks,
Steph

I believe the bias is already accounted for in the SVM formalism without adding a column of 1's, i.e. the x's you give to SVM should really be just two-dimensional. To compute b, you can go back after you've received the alpha's from QP and calculate

b = y_m - Sum over support vectors (alpha_n * y_n * K(x_n,x_m))

where the dummy variable in the sum is n, and m is the index of any support vector. b should be the same no matter which SV you use.

bargava 06-10-2013 02:01 PM

Re: Q14 bizarre results
 
Check this documentation:
http://www.csie.ntu.edu.tw/~cjlin/libsvm/faq.html#f804

b is already added by the package.

Try an extremely large value for C (I used 1e+10)

Steph 06-10-2013 08:44 PM

Re: Q14 bizarre results
 
Thanks for the suggestions!


All times are GMT -7. The time now is 04:14 AM.

Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
The contents of this forum are to be used ONLY by readers of the Learning From Data book by Yaser S. Abu-Mostafa, Malik Magdon-Ismail, and Hsuan-Tien Lin, and participants in the Learning From Data MOOC by Yaser S. Abu-Mostafa. No part of these contents is to be communicated or made accessible to ANY other person or entity.