% % Problem EPage 392 % % Examples 9.7 % % Written by: % -- % John L. Weatherwax 2008-02-20 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- % % use hold-one-out cross validation to estimate the probability of error % 1) using a product kernel density % %forge=forge(:,1); genuine=genuine(:,1); %forge=forge(:,2); genuine=genuine(:,2); %forge=forge(:,3); genuine=genuine(:,3); %forge=forge(:,4); genuine=genuine(:,4); ncc = 0; [nc_f,d] = size(forge); [nc_g,d] = size(genuine); n = nc_f + nc_g; % test on each GENUINE point % p_f = cskernmd(genuine,forge); % construct a PDF based on the FORGED data (evaluate on the genuine data) for i=1:nc_g, % create a classifier WITHOUT the genuine point "i": genuine_train = genuine; x = genuine(i,:); genuine_train(i,:)=[]; p_g = cskernmd(x,genuine_train); if( p_g > p_f(i) ) % <- genuine WINS ncc=ncc+1; else % <- genuine LOOSES ... do nothing % end end % test on each FORGE point: % p_g = cskernmd(forge,genuine); % construct a PDF based on the GENUINE data (evaluate on the forged data) for i=1:nc_f, % create a classifier WITHOUT the forge point "i": forge_train = forge; x = forge(i,:); forge_train(i,:)=[]; p_f = cskernmd(x,forge_train); if( p_f > p_g ) % <- forge WINS ncc=ncc+1; else % <- forge LOOSES ... do nothing % end end pcc = ncc/n; fprintf('using the product kernel density estimate (for each class) we estimate pcc=%10.5f\n',pcc);