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

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Matlab solution to hw2 3de using SMO2

Page history last edited by John Leung 13 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);

 

%params

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

tol=.01;

maxiter=10^6;

eps=10^(-6);

kernel='linear';

method=0;

 

X=X1400;

Y=Y1400;

N1 = size(X, 1);

N2 = size(Xtest, 1);

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

 

%train

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

nSVs = sum(a>0)

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

 

%test

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.