LFD Book Forum Calculating w from just support vectors--numerically risky?

#1
08-29-2012, 11:58 AM
 tzs29970 Invited Guest Join Date: Apr 2012 Posts: 52
Calculating w from just support vectors--numerically risky?

In a numerically perfect world, would be exactly 0 except at the support vectors, and so would give the same result is .

On real computers, of course, we have to deal with the fact that our calculations have limited precision, and so is usually non-zero nearly everywhere.

I found that if I identified the support vectors before calculating , by looking for for some small , and then calculated just from those support vectors, I did not get a consistent . If there were 3 support vectors, sometime I'd get the same from all 3, but maybe half the time I'd get one from two of them, and the third would give a that was significantly off.

If, however, I used all the vectors to calculate , rather than just the support vectors, then I'd get the same from all the support vectors.

My speculation is that just as the values that are supposed to be 0 are off slightly due to floating point precision issues, so too are those that are supposed to be non-zero, and that when you use ALL of the 's to calculate the errors are balancing out. When you exclude the ones that were "supposed" to be 0, you increase the error in . This makes intuitive sense because the QP solver was using all the 's to try to achieve minimization, and so any error should be spread among all of them. If we only have 3 support vectors, and so only use 3 's, the error will be high because 3 is so small we get high variance. By using all the 's, the variance will be lower, and so the error is closer to the mean error, which should be zero.

Those who had errors on problems 8-10, if you just used the support vectors, and calculated from one support vector, it might be worth putting in a check to see if you get a different from different support vectors.
#2
08-29-2012, 01:26 PM
 AdrienL Member Join Date: Jul 2012 Posts: 13
Re: Calculating w from just support vectors--numerically risky?

I was wondering why my results were sometimes weird... Indeed it seems that you have to use all the vectors even those who are "negligible" to obtain the best results.
I checked that the b was consistant among all vectors but only did it visuall once... I did not think of adding an automated test.

#3
08-29-2012, 07:18 PM
 htlin NTU Join Date: Aug 2009 Location: Taipei, Taiwan Posts: 601
Re: Calculating w from just support vectors--numerically risky?

Quote:
 Originally Posted by tzs29970 In a numerically perfect world, would be exactly 0 except at the support vectors, and so would give the same result is . On real computers, of course, we have to deal with the fact that our calculations have limited precision, and so is usually non-zero nearly everywhere. I found that if I identified the support vectors before calculating , by looking for for some small , and then calculated just from those support vectors, I did not get a consistent . If there were 3 support vectors, sometime I'd get the same from all 3, but maybe half the time I'd get one from two of them, and the third would give a that was significantly off. If, however, I used all the vectors to calculate , rather than just the support vectors, then I'd get the same from all the support vectors. My speculation is that just as the values that are supposed to be 0 are off slightly due to floating point precision issues, so too are those that are supposed to be non-zero, and that when you use ALL of the 's to calculate the errors are balancing out. When you exclude the ones that were "supposed" to be 0, you increase the error in . This makes intuitive sense because the QP solver was using all the 's to try to achieve minimization, and so any error should be spread among all of them. If we only have 3 support vectors, and so only use 3 's, the error will be high because 3 is so small we get high variance. By using all the 's, the variance will be lower, and so the error is closer to the mean error, which should be zero. Those who had errors on problems 8-10, if you just used the support vectors, and calculated from one support vector, it might be worth putting in a check to see if you get a different from different support vectors.
Handling the numerical difficulty is indeed a non-trivial task. There are more issues involved than . For instance, most QP numerical solvers cannot give you the *exact* optimal alpha, but something near the optimal. In that sense, one cannot expect to be as perfect as math tells us.

In more specific SVM solvers (such as LIBSVM), support vectors are clearly identified (so there won't be the issue of ). Then, roughly speaking, is calculated from the average of possible that comes from every non-zero . The steps eliminates the effects of the numerical difficulty and that is why specific solvers are ofen preferred over generic QP solvers. Hope this helps.
__________________
When one teaches, two learn.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home General     General Discussion of Machine Learning     Free Additional Material         Dynamic e-Chapters         Dynamic e-Appendices Course Discussions     Online LFD course         General comments on the course         Homework 1         Homework 2         Homework 3         Homework 4         Homework 5         Homework 6         Homework 7         Homework 8         The Final         Create New Homework Problems Book Feedback - Learning From Data     General comments on the book     Chapter 1 - The Learning Problem     Chapter 2 - Training versus Testing     Chapter 3 - The Linear Model     Chapter 4 - Overfitting     Chapter 5 - Three Learning Principles     e-Chapter 6 - Similarity Based Methods     e-Chapter 7 - Neural Networks     e-Chapter 8 - Support Vector Machines     e-Chapter 9 - Learning Aides     Appendix and Notation     e-Appendices

All times are GMT -7. The time now is 01:51 PM.