octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: QP solves for zero instead of min?


From: Juan Pablo Carbajal
Subject: Re: QP solves for zero instead of min?
Date: Sun, 3 Aug 2014 18:51:47 +0200

On Sun, Aug 3, 2014 at 6:10 PM, Olaf Till <address@hidden> wrote:
> On Sun, Aug 03, 2014 at 05:40:07PM +0200, Juan Pablo Carbajal wrote:
>> <snip>
>> So far QP gives
>> the zero of the cost function and not the solution.
>
> Why do you think it is not the solution?
>
> Olaf
>
> --
> public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

If the problem is convex, ther eis one minimum. QP is gving a zero and
sqp finds a lower point. It seems sqp gives the solution while QP is
stuck in a zero of the cost function. I am getting this often.
It might be that I do not understand why QP can fail (if it does) or
why would there be more than one solution to a convex problem.

I am testing the primal form of SVM and sometimes I do not get the
right solution
http://en.wikipedia.org/wiki/Support_vector_machine#Primal_form

Here an example that works

N = 6;
x = [0 0.2 0.5 0.3 0.7 0.8; -0.2 -0.5 -0.1 0.3 0.4 0.1];
y = [ones(1,3) -ones(1,3)];

scatter (x(1,:),x(2,:),[],y)
axis tight

X = x.'*x;
Y = y.'*y;
H = Y.*X;
Q = -ones(N,1);
a = qp (rand(N,1),H,Q,y,0,zeros(N,1),inf(N,1));
sv = find(a>0); #support vectors

w = (y.*x)*a; #normal to the classification line
b = mean(w.'*x(:,sv) -y(sv));

# needs geometry
drawLine (createLine([0,b/w(2)],[-w(2),w(1)]))

If you change for random points N ~10 then sometimes it fails.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]