LFD Book Forum  

Go Back   LFD Book Forum > Course Discussions > Online LFD course > Homework 8

Reply
 
Thread Tools Display Modes
  #1  
Old 03-03-2013, 09:47 AM
Suhas Patil Suhas Patil is offline
Senior Member
 
Join Date: Dec 2012
Posts: 57
Default structure 'svm_node' in libsvm.

With 'libsvm' we need to initialize svm_node with training data. If my understanding is correct, there is one svm_node structure for one feature. I am failing to understand the need for two fields 'index', and 'value' in it. In case there are couple of features as given for problems in this exercise, what will be the value of index in each case? Any help. (If I try index values as 0 and 1 here the program crashes. It converges with values -1, 1 but Ein is large. I am clearly missing something.)
Thanks in advance.
Reply With Quote
  #2  
Old 03-03-2013, 10:02 AM
butterscotch butterscotch is offline
Caltech
 
Join Date: Jan 2013
Posts: 43
Default Re: structure 'svm_node' in libsvm.

the readme file in the package is a good reference.
index in svm_node refers to the feature(the readme calls this attribute) index.
For example, the postmail data set has two attributes, (and because of that we want to figure out weight for each attribute). The indexes will be 1 and 2, followed by -1 to specify that there are no more. In the example below, when the value is 0, the indexes can skip, but I don't think you have to worry about that here.

Following is the description from the readme file.
Quote:
For example, if we have the following training data:

LABEL ATTR1 ATTR2 ATTR3 ATTR4 ATTR5
----- ----- ----- ----- ----- -----
1 0 0.1 0.2 0 0
2 0 0.1 0.3 -1.2 0
1 0.4 0 0 0 0
2 0 0.1 0 1.4 0.5
3 -0.1 -0.2 0.1 1.1 0.1

then the components of svm_problem are:

l = 5

y -> 1 2 1 2 3

x -> [ ] -> (2,0.1) (3,0.2) (-1,?)
[ ] -> (2,0.1) (3,0.3) (4,-1.2) (-1,?)
[ ] -> (1,0.4) (-1,?)
[ ] -> (2,0.1) (4,1.4) (5,0.5) (-1,?)
[ ] -> (1,-0.1) (2,-0.2) (3,0.1) (4,1.1) (5,0.1) (-1,?)
Reply With Quote
  #3  
Old 03-03-2013, 10:20 AM
Suhas Patil Suhas Patil is offline
Senior Member
 
Join Date: Dec 2012
Posts: 57
Default Re: structure 'svm_node' in libsvm.

Thanks for a quick reply...was stuck here for a long time. Now hoping to solve and submit few questions from this exercise.
Reply With Quote
Reply

Thread Tools
Display Modes

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 Jump


All times are GMT -7. The time now is 09:46 AM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2020, 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.