changeset 33:74d123779d3b

create analysis script to prune and write the relevant features for each level - including an 80% classification threshold on the tree - perhaps this can be addressed
author DaveM
date Wed, 15 Mar 2017 16:33:54 +0000
parents 4bdcab1e821c
children 781ebde125cf
files analysis/analysisWorkflow.m analysis/calcLoss.m
diffstat 2 files changed, 42 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analysis/analysisWorkflow.m	Wed Mar 15 16:33:54 2017 +0000
@@ -0,0 +1,35 @@
+diary('AnalysisOutput.txt');
+dendrogram(linkList);
+currentRow = [2*listSize-1];
+
+while (~isempty(currentRow))
+    if(currentRow(1) > listSize)
+        row = currentRow(1) - listSize
+        if(~isempty(featureList{row,1}))    
+%             featureList{row,4} = calcLoss(linkList,featureList, row);
+            classList = traceLinkageToBinary(linkList,row);
+            X = data(classList>0,featureList{row,1});
+            Y = classList(classList>0);
+
+            [L,se] = loss(featureList{row,3},X,Y);
+            featureList{row,4} = [L, se];
+            
+            pDepth = max(featureList{row,3}.PruneList);
+            
+            lossVal = 1;
+            while (lossVal > 0.2 && pDepth > 1)
+                pDepth = pDepth - 1;
+                T1 = prune(featureList{row,3},'Level',pDepth);
+                lossVal = loss(T1,X,Y);
+            end
+            fprintf('Row: %d, pDepth = %d, loss = %f\n',row,pDepth,lossVal);
+            view(T1);
+            currentRow = [currentRow; linkList(row,1); linkList(row,2)];
+        end
+    end
+    currentRow = currentRow(2:end);
+end
+
+diary off
+%%
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/analysis/calcLoss.m	Wed Mar 15 16:33:54 2017 +0000
@@ -0,0 +1,7 @@
+function [l,se] = calcLoss(linkList,featureList, row)
+
+classList = traceLinkageToBinary(linkList,row);
+X = data(classList>0,featureList{row,1});
+Y = classList(classList>0);
+[l,se] = loss(featureList{row,3},X,Y);
+end