changeset 36:4af6fc2100e8

update evaluation scripts and ignore all image files
author DaveM
date Sat, 01 Apr 2017 16:57:31 +0100
parents 6155f4e3d37c
children d9a9a6b93026
files .hgignore code/aglomCluster.m evaluation/countElementOccurences.m evaluation/evalWorkflow.m evaluation/listSamplesToClusterNo.m
diffstat 5 files changed, 231 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Mar 17 09:42:18 2017 +0000
+++ b/.hgignore	Sat Apr 01 16:57:31 2017 +0100
@@ -7,3 +7,10 @@
 *.zip
 misc/csvFiles/*
 misc/matFiles
+*.eps
+*.pdf
+*.fig
+*.png
+
+
+
--- a/code/aglomCluster.m	Fri Mar 17 09:42:18 2017 +0000
+++ b/code/aglomCluster.m	Sat Apr 01 16:57:31 2017 +0100
@@ -56,7 +56,7 @@
 
 distMap = pdist(data, distanceMetric);
 linkList = linkage(distMap, clusterMethod);
-% [~,T] = dendrogram(linkList,numClusters);
+[~,T] = dendrogram(linkList,numClusters,'Orientation','left');
 
 
 end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/evaluation/countElementOccurences.m	Sat Apr 01 16:57:31 2017 +0100
@@ -0,0 +1,15 @@
+function [LU,occ] = countElementOccurences(L)
+
+LU = unique(L);
+occ = zeros(length(LU),1);
+
+for i = 1:length(L)
+    for ii = 1:length(LU)
+        if(strcmp(L{i}, LU{ii}))
+%             fprintf('L= %s, LU= %s \n',L{i},LU{ii});
+            occ(ii) = occ(ii) + 1;
+        end
+    end
+end
+
+end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/evaluation/evalWorkflow.m	Sat Apr 01 16:57:31 2017 +0100
@@ -0,0 +1,186 @@
+diary('Evaluation.txt');
+addpath('../code');
+
+% dendrogram(linkList);
+% listSize = size(data,1);
+% currentRow = [2*listSize-1];
+
+% currentRow = [8930; 8959; 8928; 8956; 8951; 8954; 8942; 8964; 8961; 8962; 8949; 8960];
+currentRow = [60;49;65;62;67;68;42;63;66];
+currentRow = currentRow + 8900;
+[LU_all,occ_all] = countElementOccurences(catList);
+
+result = cell(0);
+while (~isempty(currentRow))
+    row = currentRow(1);
+%             featureList{row,4} = calcLoss(linkList,featureList, row);
+    classList = traceLinkageToBinary(linkList,row);
+    L = catList(classList>0);
+    [LU,occ] = countElementOccurences(L);
+
+    fprintf('Row: %d\n',row);
+    fprintf('Row, \t Category, \t\t Percentage of cat \t percentage of row\n');
+    rowTot = sum(occ);
+    for i = 1:length(LU)
+        occPercentage = occ(i)/ occ_all(find(strcmp(LU_all,LU{i})));
+        occRowPercentage = occ(i)/ rowTot;
+        fprintf('%d, \t %s, \t \t %f, \t %f \n',row,LU{i},occPercentage, occRowPercentage);
+
+        resultRow = size(result,1)+1;
+        result{resultRow,1} = row;
+        result{resultRow,2} = LU{i};
+        result{resultRow,3} = occPercentage;
+        result{resultRow,4} = occRowPercentage;
+    end
+
+    currentRow = currentRow(2:end);
+end
+
+diary off
+%%
+
+warning('off','MATLAB:legend:IgnoringExtraEntries')
+diary('Evaluation2.txt');
+currentRow = [60;49;65;62;67;68;42;63;66];
+currentRow = currentRow + 8900;
+LU_all = strrep(LU_all,'_',' ')
+% currentRow = [8960; 8956; 8951; 8954; 8942; 8964; 8961; 8962; 8949; 8960];
+% imFolder = 'im/';
+% mkdir(imFolder)
+thresh = 0.05;
+ledList = {};
+
+for i = 1:length(currentRow)
+    row = currentRow(i);
+    led = strrep(result([result{:,1}] == row,2),'_',' ');
+    toPlot = [result{[result{:,1}] == row,4}];
+    useMap = toPlot>thresh;
+    toPlot = toPlot(useMap);
+    led = led(useMap);
+    ledList = [ledList;led(1:length(toPlot))];
+    
+end
+
+ledU_name = unique(ledList);
+ledU = zeros(length(ledU_name),1);
+for l = 1:length(ledU_name)
+    ledU(l) = find(strcmp(ledU_name(l),LU_all));
+end
+
+%%
+% subplot(3,4)
+currentRow = [60;49;65;62;67;68;42;63;66];
+currentRow = currentRow + 8900;
+fig1 = figure('Position',[100 100 500 500]); 
+hold on;
+set(gca,'color','none');
+tcm = colormap(jet(length(ledU)));
+p = struct;
+i = 1;
+while (~isempty(currentRow))
+    p(i).row = currentRow(1);
+%     M = result([result{:,1}] == row,:);
+%     test = strrep(L
+    p(i).led = strrep(result([result{:,1}] == p(i).row,2),'_',' ');
+    toPlot = [result{[result{:,1}] == p(i).row,4}];
+%     toPlot = toPlot;
+    
+    p(i).useMap = toPlot>thresh;
+    p(i).toPlot = toPlot(p(i).useMap);
+    p(i).led = p(i).led(p(i).useMap);
+    xy = [mod(i-1,3)*0.3,0.66-(floor((i-1)/3)*0.33),0.3,0.3];
+    p(i).plot = subplot('position',xy);
+    h = pie(p(i).toPlot);
+    title(['Cluster ' num2str(i)],'FontSize',12,'FontWeight','normal','Interpreter','tex');
+    ht = findobj(h,'Type','text');
+    for ii = 1:length(ht)
+        ht(ii).Visible = 'off';
+    end
+    hp = findobj(h,'Type','patch');
+    for ii = 1:length(hp)
+%         p(i).led(ii)
+        featName = find(strcmp(LU_all,p(i).led(ii)));
+        colToUse = find(featName==ledU);
+        hp(ii).FaceColor = tcm(colToUse,:);
+    end
+    p(i).h = h;
+    currentRow = currentRow(2:end);
+    i = i + 1;
+    
+end
+% hSub = subplot(4,1,4); plot(1,1,1,1,1,1,1,1);
+% legend(led,'position',get(hSub,'position'),'Orientation','vertical','Box','off','FontSize',12);
+saveas(gcf,'t1_5','fig');
+saveas(gcf,'t1_5','png');
+print('t1_5.eps','-depsc2');
+
+% L_p = legend(led,'Location','bestoutside','Orientation','vertical','Box','off','FontSize',12);
+
+% saveas(gcf,'t2','fig');
+% saveas(gcf,'t2','png');
+diary off
+%%
+
+figure;
+temPlot = ones(length(ledU),1);
+h = pie(temPlot);
+
+% led = strrep(result([result{:,1}] == p(i).row,2),'_',' ');
+
+set(h,'Visible','off');
+ht = findobj(h,'Type','text');
+for ii = 1:length(ht)
+    ht(ii).Visible = 'off';
+end
+hp = findobj(h,'Type','patch');
+for ii = 1:length(hp)
+    hp(ii).FaceColor = tcm(ii,:);
+end
+legend(ledU_name,'Location','north','Orientation','vertical','Box','off','FontSize',14);
+
+saveas(gcf,'leg_5','fig');
+saveas(gcf,'leg_5','png');
+print('leg_5.eps','-depsc2');
+
+
+% %%
+% row = 8930;
+% %     M = result([result{:,1}] == row,:);
+% %     test = strrep(L
+% led = strrep(result([result{:,1}] == row,2),'_',' ');
+% toPlot = [result{[result{:,1}] == row,4}];
+% toPlot = toPlot;
+% 
+% toPlot = toPlot(toPlot>thresh);
+% figure;
+% h = pie(toPlot);
+% 
+% ht = findobj(h,'Type','text');
+% for i = 1:length(ht)
+%     ht(i).Visible = 'off';
+% end
+% 
+% %     [result{[result{:,1}] == 8930,4}]
+% legend(led,'Location','eastoutside','Orientation','vertical','Box','off','FontSize',12);
+% tit_graph = ['Label Distribution for Cell ' num2str(row)];
+% title(tit_graph)
+% tit_f = [imFolder 'pie_' num2str(row)];
+% set(gca,'color','none')
+% saveas(gcf,tit_f,'fig');
+% saveas(gcf,tit_f,'png');
+% 
+% 
+% 
+% %%
+% 
+% led = strrep(result([result{:,1}] == row,2),'_',' ');
+% toPlot = [result{[result{:,1}] == row,4}];
+% toPlot = toPlot/100;
+% toPlot = toPlot(toPlot>thresh);
+% toPlot
+% h = pie(toPlot)
+% hp = findobj(h,'Type','patch');
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/evaluation/listSamplesToClusterNo.m	Sat Apr 01 16:57:31 2017 +0100
@@ -0,0 +1,22 @@
+for i = 1:size(ucl,1)
+    if(mod(i-1,2))
+        endLine =' \\';
+    else
+        endLine = ' & ';
+    end
+        
+    disp([ucl{i} ' & ' num2str(ucl_count(i)) endLine])
+
+end
+
+%%
+diary('ClassEvaluation.txt');
+
+for i = 1:length(p)
+   i
+   for ii = 1:length(p(i).toPlot)
+       disp([p(i).led{ii} ' & ' num2str(p(i).toPlot(ii))])
+   end
+    
+end
+diary off
\ No newline at end of file