sspca
Semi-supervised classification by PCA, Sonar example, 250 repitions
PRTools and PRDataSets should be in the path
Download the m-file from here. see http://37steps.com/prtools for more.
Contents
Get data
a = sonar; a = setprior(a,getprior(a)); % set priors equal to class frequencies c = getsize(a,3); % get number of classes delfigs % delete figures
Initialization
itermax = 250; % run over itermax repititions classf = setname(qdc,'QDA');% define classifier and its name T = [2 3 4 5:2:11 15:5:40]; % training set sizes for learnig curves S = [4 5 7]; % desired PCA dimensions n = itermax*numel(T)*numel(S); q = sprintf('running over %i experiments: ',n); prwaitbar(n,q); es = zeros(numel(T),numel(S),itermax); % space for supervised results eu = zeros(numel(T),numel(S),itermax); % space for semisupervised results
Process
r = 0; for iter = 1:itermax for j=1:numel(T) % run over training set sizes randreset(100*iter+j); % take care of reproducability [X,Y] = gendat(a,T(j)*ones(1,c)); % trainset and testset for i=1:numel(S) % run over all dims r = r+1; prwaitbar(n,r,[q num2str(r)]); % report progress es(j,i,iter) = Y*(X*(pcam(+X,S(i))*classf))*testc; % supervised eu(j,i,iter) = Y*(X*(pcam(+a,S(i))*classf))*testc; % semisupervised end end end prwaitbar(0)
Present results
semilogx(T,mean(es,3)); hold on; semilogx(T,mean(eu,3),'--'); linewidth(1.5); legendpar = cell(1,numel(S)); for j=1:numel(S) legendpar{j} = ['super dim = ' num2str(S(j))]; end for j=1:numel(S) legendpar{j+numel(S)} = [' semi dim = ' num2str(S(j))]; end legend(legendpar{:},'Location','SouthWest'); title([getname(classf) ', Learning curves ' getname(a) ' dataset']) xlabel('# training objects per class') ylabel(['Averaged class. error (' num2str(itermax) ' exp.)']); fontsize(14)
Adapt to this problem
set(gcf,'Position',[23 57 847 468]); axis([2 40 0.2 0.51]) set(gca,'xtick',[2 4 10 20 40])