[f1,f2]=simplefeat('*h4*.png'); t(:,1)=f1; t(:,2)=f2; train=t(1:10,:); test=t(11:20,:); [f1,f2]=simplefeat('*tfr*.png'); t(:,1)=f1; t(:,2)=f2; train(11:20,:)=t(1:10,:); test(11:20,:)=t(11:20,:); % plot the training data for the first half as blue circles and the % second half as green diamonds plot(train(1:10,1),train(1:10,2),'bo',train(11:20,1),train(11:20,2),'gd'); hold on % plot the test data for the first half as blue x's and the second half % as green plusses plot(test(1:10,1),test(1:10,2),'bx',test(11:20,1),test(11:20,2),'g+'); hold off % plot decision boundary ninc=200; [pltx,plty]=finddecisionboundary(train(1:10,:),train(11:20,:),1,2,ninc) % plot all of the points that were on the decision boundary hold on plot(pltx,plty,'k.'); hold off % generate "labels" for each row showing that the first half is in class 1 group=[repmat(1,10,1); repmat(2,10,1)]; % train a linear classifier with the training data and evaluate it with % the test data cl=classify(test,train,group); % the resulting vector shows which class the classifier thinks each test % point is in cl % count true +, false +, true -, false - and build confusion matrix tp=length(find(cl(1:10)==1)); fp=length(find(cl(11:20)==1)); fn=length(find(cl(1:10)==2)); tn=length(find(cl(11:20)==2)); confmat=[tp fn; fp tn]