Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: using fminsearch for optimizing svm parameters
Replies: 1   Last Post: Feb 15, 2013 8:07 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Alan Weiss

Posts: 1,256
Registered: 11/27/08
Re: using fminsearch for optimizing svm parameters
Posted: Feb 15, 2013 8:07 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 2/14/2013 5:45 PM, Hadi Masoud wrote:
> Hi
>
> I am using fminsearch to optimize svm parameters: rbf_sigma,
> boxconstraint.
>
> fminsearch seems to always get stuck in a local minimum and does not
> give me results even close to the minimum. Can someone please tell me
> if they see something wrong in my code:
>
>
> [d1 d2]=size(SelectedTable);
> Xs=SelectedTable(:,1:(d2-1));
> Y1=SelectedTable(:,d2);
>
> c= cvpartition(d1,'kfold',10);
>
> minfn = @(z)crossval('mcr',Xs,Y,'Predfun', ...
> @(xtrain,ytrain,xtest)cross_fun(xtrain,ytrain,...
> xtest,exp(z(1)),exp(z(2))),'partition',c);
>
> opts = optimset('Display','iter','TolX',0.05,'TolFun',0.05);
>
> [searchmin fval1 exitflag] = fminsearch(minfn,2*randn(1,2),opts)


Since your code seems to be taken directly from a documentation example
http://www.mathworks.com/help/bioinfo/ug/support-vector-machines-svm.html#bs3tbev-16
I imagine that there is no error in the code.

You might do better to first make a grid of search points spaced
exponentially apart, such as
y = logspace(-3,3,10);
[xx,yy] = meshgrid(y);
z = [xx(:),yy(:)];
Use z as the start of 100 different local searches--fminsearch will
still get stuck in local minima, but you have a lot of starting points
to search through.

If you like, you can add random perturbations to the start points, or
scale them differently (I was just guessing at an appropriate range of
parameters).

Good luck,

Alan Weiss
MATLAB mathematical toolbox documentation



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.