Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: using fminsearch for optimizing svm parameters
Posted:
Feb 15, 2013 8:07 AM
|
|
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
|
|
|
|