LFD Book Forum  

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

Reply
 
Thread Tools Display Modes
  #11  
Old 08-30-2012, 08:57 AM
DeanS DeanS is offline
Member
 
Join Date: Jul 2012
Posts: 16
Default Re: Libsvm

I am trying to get the digits data in the form that Libsvm (the windows command line version) can use. I need to convert the two input data into the form '1:0.12121'. In other words, append the integer and :. Since I am new to Matlab (which I have used throughout the course), can anyone explain how to transform the data. While I can make it into a string, I'm not sure this will be correctly read by Libsvm.

Thanks.
Reply With Quote
  #12  
Old 08-30-2012, 10:55 AM
TonySuarez TonySuarez is offline
Member
 
Join Date: Jul 2012
Location: Lisboa, Portugal
Posts: 35
Default Re: Libsvm

In the link about Octave (hope it is == to Matlab in this respect)


http://octave.1599824.n4.nabble.com/...td1632472.html

there is:

------------

>I would like to read an ascii data file with 3 columns of integers
>separated by a space, and an unknown number of rows into 3 vectors or a
>matrix with 3 columns.

Try

data = load ("-ascii", "yourfile.txt")

Ben

-------------

HTH
Reply With Quote
  #13  
Old 08-30-2012, 10:58 AM
DeanS DeanS is offline
Member
 
Join Date: Jul 2012
Posts: 16
Default Re: Libsvm

Thanks. I will try it later today.
Reply With Quote
  #14  
Old 08-30-2012, 03:05 PM
invis invis is offline
Senior Member
 
Join Date: Jul 2012
Posts: 50
Default Re: Libsvm

Pleasy, some one who understand how this libsvm works tell us how to go through week 8 problems.

I tryed to install libsvm in Octave, thats what I have:
Quote:
>> cd C:\Octave\libsvm-3.12\matlab

>> make
warning: unable to find mkoctfile in expected location: `C:\Octave\OCTAVE~2.2\bin\mkoctfile-3.6.2'
warning: mkoctfile exited with failure status
warning: unable to find mkoctfile in expected location: `C:\Octave\OCTAVE~2.2\bin\mkoctfile-3.6.2'
warning: mkoctfile exited with failure status
warning: unable to find mkoctfile in expected location: `C:\Octave\OCTAVE~2.2\bin\mkoctfile-3.6.2'
warning: mkoctfile exited with failure status
warning: unable to find mkoctfile in expected location: `C:\Octave\OCTAVE~2.2\bin\mkoctfile-3.6.2'
warning: mkoctfile exited with failure status

>> mex -setup
mkoctfile: unrecognized argument -setupwarning: unable to find mkoctfile in expected location: `C:\Octave\OCTAVE~2.2\bin\mkoctfile-3.6.2'
warning: mkoctfile exited with failure status
Then using *.exe files:
Quote:
C:\Octave\libsvm-3.12\windows>svm-train -t 1 -d 2 -g 1 -r 1 -v 10 -c 0.01 features.train
actually dont know why the kernel is polynomial:
1 -- polynomial: (gamma*u'*v + coef0)^degree
but didnt find (1+ x_n^T x_m)^Q in list

Thats what I have in last iteration:
Quote:
optimization finished, #iter = 579
nu = 0.936893
obj = -11.580000, rho = -1.000000
nSV = 1158, nBSV = 1158
Total nSV = 6386
Cross Validation Accuracy = 16.3764%
And features.model file didnt appears.

Actually I am prefer using my code from week7, but with upper bound C and some others. But this 7291 X 7291 matrix...
Reply With Quote
  #15  
Old 08-30-2012, 04:52 PM
jakvas jakvas is offline
Member
 
Join Date: Jul 2012
Posts: 17
Default Re: Libsvm

I don't get any reasonable output:/

I made training sets where in ex. 0vsall i changed every zero with +1 and every other label number with -1 then i fed it libsvm using "svm-train.exe -t 1 -d 2 -g 1 -r 1 -v 10 -c 0.01 0vsall.train 0vsall.model"

after that i fed the model and the training set to svm.predict.exe but it just says everything is -1 (so not a 0) which essentialy means every 0 is mis clasified but that can't be the point of the exercise right? Can someone tell me where I'm doing something wrong?
Reply With Quote
  #16  
Old 08-31-2012, 10:25 AM
itooam itooam is offline
Senior Member
 
Join Date: Jul 2012
Posts: 100
Default Re: Libsvm

Quote:
Originally Posted by jakvas View Post
I don't get any reasonable output:/

I made training sets where in ex. 0vsall i changed every zero with +1 and every other label number with -1 then i fed it libsvm using "svm-train.exe -t 1 -d 2 -g 1 -r 1 -v 10 -c 0.01 0vsall.train 0vsall.model"

after that i fed the model and the training set to svm.predict.exe but it just says everything is -1 (so not a 0) which essentialy means every 0 is mis clasified but that can't be the point of the exercise right? Can someone tell me where I'm doing something wrong?
Jakvas, what you write could actually be correct, one of the problems when using SVM's is that if the classifications in your data are not equal in size, i.e, in this case we have 90% -1s and 10% of 1s (assuming there are 10 classifiers I haven't looked?). It will train to the 90% classifier (imagine a plane above all your data point - doesn't split it - still gives a good estimate for the -1s). If you transform your data to have equal classifiers then I would expect it to train much better. Try it with the -wi parameter to equal it out? I will write back when I have done some work on this. I suspect though, this is the lesson of the homework? So for answering I don't think we should be using -wi but is a useful parameter to know for when dataset classifiers are not equally distributed in your training data.
Reply With Quote
  #17  
Old 08-31-2012, 11:20 AM
Willem Willem is offline
Member
 
Join Date: Jun 2012
Posts: 22
Default Re: Libsvm

Interesting suggestion! I was also trying a couple of hours to find my bug when I realized this is actually the result. Will look into wi par to, quite curious if that works or if the dataset itself is just not separable.
Reply With Quote
  #18  
Old 08-31-2012, 11:43 AM
jakvas jakvas is offline
Member
 
Join Date: Jul 2012
Posts: 17
Default Re: Libsvm

well I thought so too (even during the lectures I wondered what to do not to skew the result by having unequal ammounts of +1 and -1 data) but since it's a 2nd order kernel it would benefit from even circling only one of the +1 labeled values yet it won't even do that which seems unreasonable.
Reply With Quote
  #19  
Old 08-31-2012, 11:55 AM
itooam itooam is offline
Senior Member
 
Join Date: Jul 2012
Posts: 100
Default Re: Libsvm

Let me know how you get on with the wi? I won't be able to test until tomorrow so will post my findings, if any, then?

I found this whch explains in more detail:

http://www.csie.ntu.edu.tw/~cjlin/papers/libsvm.pdf

See section 6 - Unbalanced Data and Solving the Two-variable (page 26)
Reply With Quote
  #20  
Old 08-31-2012, 12:08 PM
jakvas jakvas is offline
Member
 
Join Date: Jul 2012
Posts: 17
Default Re: Libsvm

oh yeah you can balance using -wi but don't do it (if youd have to it would be stated in the homework) also there is no point in balancing since well.... any number occurs fewer times than all the others combined so in essence you'd be balancing a skew which should be there (also I think it might be some sort of data snooping(?))

anyway I found my problem hint: make sure your input has the correct form
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 11:33 PM.


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.