• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Finally, you can manage your Google Docs, uploads, and email attachments (plus Dropbox and Slack files) in one convenient place. Claim a free account, and in less than 2 minutes, Dokkio (from the makers of PBworks) can automatically organize your content for you.


Matlab solution to hw2 3de using SMO2

Page history last edited by John Leung 10 years, 10 months ago

Solution to HW2 #3d,e using ready made SMO2 from Intro to PR book:

http://cgi.di.uoa.gr/~stpatrec/welcome3d.html -pkg download

http://www.elsevierdirect.com/companion.jsp?ISBN=9780123744869 -pkg divided by chapters

Result is the same .5% error rate as Peter's solution, but training seems quite a bit faster and allows better param adjustments.

Questions? email John at jklemail@gmail.com


%read data

[X1400, tokens, Y1400] = readMatrix('data/MATRIX.TRAIN.1400');

X1400 = full(X1400);

[Xtest, tokens, Ytest] = readMatrix('data/MATRIX.TEST');

Xtest = full(Xtest);



C=.1;  %.1 gave best result from trying .5, 1









N1 = size(X, 1);

N2 = size(Xtest, 1);

Y(Y==0) = -1;  %convert 0's to -1's for smo



[a, b, w] = SMO2(X, Y', kernel,0,0,C,tol,maxiter,eps,method);

nSVs = sum(a>0)

marg = 2/sqrt(sum(w.^2))



h = w*Xtest' + b;

h(h>0) = 1;

h(h<0) = 0;

errate = sum(h~=Ytest)/N2



Comments (0)

You don't have permission to comment on this page.