Skip to content
Snippets Groups Projects
Commit 4c952600 authored by ac_cx's avatar ac_cx
Browse files

updates from cx

parent 24194ca1
Branches
No related tags found
No related merge requests found
Showing
with 124 additions and 1 deletion
% NCDM
% X is a 1-D cell array of images
% eg
% im = rand(100,100); ncd=ncd.imNCDM({im,im})
% im = rand(100,100); ncd=NCD.imNCDM({im,im})
%
function [ncd,GX]= imNCDM(X)
ncd=NaN;
......
File added
function [kOD,mx,sd,clusterConfusion]=getKfixed(xDigits,kMax,NUMBER_OF_SAMPLES,clusterConfusion)
dx=[];
idx=[];
idxsp=[];
kTrue=length(unique([xDigits.idxTrue]));
dDigits=MNISTdistance(xDigits);
for k=1:kMax
idxsp=Cluster.SpectralCluster(dDigits,k);
if k==kTrue
clusterConfusion=updateConfusion(xDigits,clusterConfusion,kTrue,kMax,idxsp);
end
dx(k)=deltaK(xDigits,idxsp);
end
% mx=mean(dx,2,'omitnan');
% mx=min(dx,[],2);
% sx=sort(dx,2);
% sx=sx(:,1:100);
mx=mean(dx,2,'omitnan');
sd=std(dx,0,2,'omitnan');
% account for simulation error, as in gap statistic
sd=sd.*sqrt(1+1/NUMBER_OF_SAMPLES);
kOD=find(mx(1:end-1)-sd(1:end-1)>mx(2:end),1,'first');
if ~isempty(kOD)
kOD=kOD+1;
% fprintf(1,'sd :: kOD=%d\n',kOD);
else
deltaMx=diff(mx)';
kOD=find(deltaMx>0,1,'first');
if isempty(kOD)
od=max(deltaMx(deltaMx<0));
kOD=find(deltaMx==od,1,'first');
% fprintf(1,'max(deltaMX<0) :: kOD=%d\n',kOD);
else
% fprintf(1,'deltaMX>0 :: kOD=%d\n',kOD);
end
end
4;
% outfolder='./results/';
% if ~exist(outfolder,'dir')
% mkdir(outfolder);
% mkdir(fullfile(outfolder,'true'));
% mkdir(fullfile(outfolder,'false'))
% end
path(path,'..');
tblResults=table();
maxDigits=[0,1,2,3,8,9];
CARDINALITY=10;
clusterConfusion={};
rgResults=[]; % maxDigit,trial,iteration
kMax=12;
NUMBER_OF_TRIALS=100;
NUMBER_OF_SAMPLES=1000;
p=startParallel();
% outname=['getK5k' datestr(now,'mm-dd-yyyy') '.mat']
NDIGITS=length(maxDigits);
kConfusion=zeros(10,kMax);
for nTrial=1:NUMBER_OF_TRIALS
for d=1:NDIGITS
target=[0:maxDigits(d)];
K=length(target);
xDigits=getNISTdigits(target,CARDINALITY);
[kpred,mx,sd,clusterConfusion]=getK(xDigits,kMax,NUMBER_OF_SAMPLES,clusterConfusion);
rgResults(d,nTrial)=kpred;
kConfusion(K,kpred)=kConfusion(K,kpred)+1;
% drawResults(kpred,K,mx,sd,outfolder,nTrial);
5;
end
% if 0==mod(nTrial,20)
% clusterConfusion;
% kConfusion
% mean(rgResults,2)
% end
5;
end
toc()
save(outname);
% idxKPred=tblResults.kPred==K;
% idxKGap=tblResults.kGap==K;
% idxKSP=tblResults.kSP==K;
% accPredGapSP=[length(find(idxKPred))/length(idxKPred),length(find(idxKGap))/length(idxKGap)...
% length(find(idxKSP))/length(idxKSP)]
% sciPred=bootci(20000,@mean,idxKPred)
% sciGap=bootci(20000,@mean,idxKGap)
% sciSP=bootci(20000,@mean,idxKSP)
File added
File added
File added
File added
File added
File added
File added
File added
File added
File added
mod5
[0:1] 0.86
mod4
[0:1] 0.99
[0:2] 0.94 [3.155;3.222]
[0:8] 0.97
[0:9] 0.96
File added
load 'getK5k10-15-2021.mat'
truncResults=[];
for i=1:100
rg2=rgResults(:,(i-1)*50+1:i*50);
truncResults(:,i)=mean(abs(rg2),2,'omitnan');
end
bootci(20000,@mean,truncResults')
% length(find(tr2(2,:)==2))
% length(find(tr2(3,:)==3))
% length(find(tr2(4,:)==4))
% length(find(tr2(5,:)==9))
% length(find(tr2(6,:)==10))
\ No newline at end of file
File added
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment