Train_SVM and add_struct_fields

271 views
Skip to first unread message

Olga

unread,
Mar 30, 2011, 12:19:08 PM3/30/11
to Princeton MVPA Toolbox for Matlab
Hi guys,

I've been trying to use train_svm and got several errors, which makes
me wonder whether the function I am using (which I got from the latest
version of the toolbox) is up to date.

The first error I got was :

??? Undefined function or method 'add_struct_fields' for input
arguments of type 'struct'.

Error in ==> train_svm at 53
args = add_struct_fields(in_args,defaults);

Error in ==> cross_validation at 233
scratchpad =
train_funct_hand(trainpats,double(traintargs),class_args,cv_args);

I think that the function 'add_struct_fields' is no longer in the
toolbox (I found it in the older versions.) I read somewhere in the
Google group that it had been replaced by propval, so I tried to use
propval instead, but then I got this error:
1??? Error using ==> propval at 201
Property 'train_funct_name' has no default value.

Does anyone know if there is a more updated version of train_svm
somewhere / has anyone encountered these errors?

Thank you in advance!
Olga

Olga

unread,
Apr 19, 2011, 5:30:08 PM4/19/11
to Princeton MVPA Toolbox for Matlab
Hi everyone,

Does anyone have any updated / customized train_svm functions for
Linux? It seems like it would be good to update the current SVM
functions provided by the toolbox, so any suggestions would be really
appreciated!

Thank you in advance,
Olga

Aidan Horner

unread,
Apr 25, 2011, 6:19:21 AM4/25/11
to Princeton MVPA Toolbox for Matlab
I just wanted to second this - I had similar problems using SVM
functions a while back. Given how wide spread SVMs are in the
literature it would be good if this was better supported in the
toolbox.

Any help appreciated!
Aidan

Garrett McGrath

unread,
Apr 25, 2011, 11:31:42 AM4/25/11
to Princeton MVPA Toolbox for Matlab
Just looking into this quickly, there seems to be 2 different versions
of train_svm in the toolbox currently. The one in the 'trunk/
contribs' folder does indeed use the 'add_struct_fields' command,
however there is a second version of the file in the /trunk/core/
learn/ that does not invoke this function (http://code.google.com/p/
princeton-mvpa-toolbox/source/browse/trunk/core/learn/train_svm.m).
I'll take a look at the files themselves, but if you could test
against this version by excluding the 'contribs' area from your path
that would be very helpful.
-Garrett

Olga

unread,
Apr 26, 2011, 12:27:52 PM4/26/11
to Princeton MVPA Toolbox for Matlab
Hi Garrett,

I tried only including the path to core/learn, but then I get this
error:

??? Undefined function or method 'svmlearn' for input arguments of
type 'double'.

Error in ==> train_svm at 83
[scratch.model] =
svmlearn(trainpats',train_max_idx',args.kernelstring);

Error in ==> cross_validation at 235
scratchpad =
train_funct_hand(trainpats,traintargs,class_args,cv_args);

I can't find the function svmlearn anywhere...

Thanks,
Olga


On Apr 25, 11:31 am, Garrett McGrath <gmcgrath815s...@gmail.com>
wrote:

Francisco Pereira

unread,
Apr 26, 2011, 12:30:03 PM4/26/11
to mvpa-t...@googlegroups.com
Perhaps it's a C function that needs to be built with mex? (don't
recall which of SVMlight or libsvm is being wrapped but if I remember
correctly both needed this).

f

> --
> You received this message because you are subscribed to the Google Groups "Princeton MVPA Toolbox for Matlab" group.
> To post to this group, send email to mvpa-t...@googlegroups.com.
> To unsubscribe from this group, send email to mvpa-toolbox...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mvpa-toolbox?hl=en.
>
>

Garrett McGrath

unread,
Apr 26, 2011, 2:46:02 PM4/26/11
to mvpa-t...@googlegroups.com
There is some additional setup required for the SVM functions that I failed to mention previously.  An RTF file is included in the /learn directory detailing the installation procedure for this.  I'll make an effort to move this documentation over to the web page so it's more clear.  It should be noted as this is an outside project these files may have moved from the instructions or been upgraded in a way that makes them incompatible with the current MVPA usage.  I'd be happy to try and help fix the train_ code if this is the case.
-Garrett

MS Al-Rawi

unread,
Apr 26, 2011, 7:20:22 PM4/26/11
to mvpa-t...@googlegroups.com
Maybe you could try svmtrain & svmclassify that come with matlab's
bioinformatics toolbox (if you have this toolbox installed)
http://www.mathworks.com/help/toolbox/bioinfo/ref/svmclassify.html

Note: test_svm uses the function svmclassify (compiled from Jaochims's code) and
matlab's bioinformatics toolbox has the same function name too!

Regards,
Rawi

Ryan Mruczek

unread,
Apr 27, 2011, 9:54:08 AM4/27/11
to Princeton MVPA Toolbox for Matlab
I have found that the LIBSVM and LIBLINEAR packages are easier to work
with as the authors provide pre-compiled files. Here is a link to a
previous thread that includes the corresponding train_ and test_
functions for both. The thread also has a link to the LIBLINEAR and
LIBSVM websites.

http://groups.google.com/group/mvpa-toolbox/browse_thread/thread/893f4922013476e4/f8ffe99a30debc44?#f8ffe99a30debc44

One small change to the code in that the variable TRAINPATS should be
converted to a double before converting the a sparse matrix in the
train functions (TRAIN_LIBSVM and TRAIN_LIBLINEAR). E.g.,
[scratch.model] =
train(trainlabs',sparse(double(trainpats))',args.training_options);

This bug fix was sent to me by Nicolas Schuck, who was getting errors
without converting to double precision.

I will work with Garret to get these functions in the main code for
future releases/versions.

Ryan


On Apr 26, 7:20 pm, MS Al-Rawi <rawi...@yahoo.com> wrote:
> Maybe you could try svmtrain & svmclassify that come with matlab's
> bioinformatics toolbox (if you have this toolbox installed)http://www.mathworks.com/help/toolbox/bioinfo/ref/svmclassify.html
Reply all
Reply to author
Forward
0 new messages