Skip to content

Commit

Permalink
path change
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelkalunga committed Aug 27, 2015
1 parent 8ce024a commit 97e2f16
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 18 deletions.
154 changes: 144 additions & 10 deletions plots.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
clear all
% load classProb
load classProb_3class.mat; NbrSess = subNbrOfSess;
load ('./results/classProb_3class.mat'); NbrSess = subNbrOfSess;
Labels = Labels+1;
sub11.Labels = Labels(:,:,1:NbrSess(11),11);
sub11.classProb = classProb(:,:,:,1:NbrSess(11),11);
Expand Down Expand Up @@ -99,7 +99,7 @@
%% PLOT AVERAGE CLASSIFICATION ERROR VS. PROBABILITY THRESHOLD
clear all
% load classProb
load classProb_3class.mat; NbrSess = subNbrOfSess;
load('./results/classProb_3class.mat'); NbrSess = subNbrOfSess;
Labels = Labels+1;
probIdx = 1;
for prob = 0:0.1:1
Expand Down Expand Up @@ -190,7 +190,7 @@
% ylim(hAx(2),[0 0.8])

%% PLOT IMPACT OF W (window size/tLen) on online clasification accuracy and ITR
load online_curve_tlen_3class_new.mat
load('./results/online_curve_tlen_3class_new.mat')
meanAcc = mean(subAcMean,2);
stdAcc = std(subAcMean,[],2);
meanItr = mean(itr3,2);
Expand Down Expand Up @@ -219,7 +219,7 @@
%##################################################################################################################################################################
clear all
% load classProb
load classProb_4class.mat; NbrSess = subNbrOfSess;
load('./results/classProb_4class.mat'); NbrSess = subNbrOfSess;
Labels = Labels+1;
sub11.Labels = Labels(:,:,1:NbrSess(11),11);
sub11.classProb = classProb(:,:,:,1:NbrSess(11),11);
Expand Down Expand Up @@ -316,7 +316,7 @@
%% PLOT AVERAGE CLASSIFICATION ERROR VS. PROBABILITY THRESHOLD
clear all
% load classProb
load classProb_4class.mat; NbrSess = subNbrOfSess;
load('./results/classProb_4class.mat'); NbrSess = subNbrOfSess;
Labels = Labels+1;
probIdx = 1;
for prob = 0:0.1:1
Expand Down Expand Up @@ -402,7 +402,7 @@
% ylim(hAx(2),[0 0.8])

%% PLOT IMPACT OF W (window size/tLen) on online clasification accuracy and ITR
load online_curve_tlen_4class.mat
load('./results/online_curve_tlen_4class.mat')
meanAcc = mean(subAcMean,2);
stdAcc = std(subAcMean,[],2);
meanItr = mean(itr3,2);
Expand All @@ -428,7 +428,7 @@
ylim(hAx(2),[0 max(meanItr)+max(stdItr)])
%% PLOT CONFUSION MATRIX AND ROC SPACE
clear all
load online_curve_potato_4class.mat
load('./results/online_curve_potato_4class.mat')
LabelAll = LabelAll+1;
Yall = Yall+1;
targets = zeros(numel(unique(LabelAll)), numel(LabelAll));
Expand Down Expand Up @@ -536,8 +536,142 @@
spaceplots; %cutt off blank margins (from matlab filexchage)
end

%% COMPUTE AND PLOT ROC CURVE BASED ON RHO
clear all
% load classProb
load('./results/classProb_4class.mat'); NbrSess = subNbrOfSess;
Labels = Labels+1;

rho4 = [];
label4 = [];
for sub = 1:12
sub_labels = Labels(:,:,1:NbrSess(sub),sub);
sub_prob = classProb(:,:,:,1:NbrSess(sub),sub);
Lsub = [];
rho = [];
label = [];
for sess = 1:NbrSess(sub)
for tr = 1:8*size(classProb,1)
Lsub(tr,sess) = sub_labels(tr,1,sess);
%rho(tr,:,sess) = sub_prob(:,:,tr,sess); %- Probability of groundtruth class (To be used as scrore in ROC)
%label(tr,:,sess) = repmat(Lsub(tr,sess),1,numel(rho(tr,:,sess)));

c = zeros(numel(unique(sub_labels)),1);
c(Lsub(tr,sess)) = 1;
rho(tr,:,:) = sub_prob(:,:,tr,sess); %- Probability of groundtruth class (To be used as scrore in ROC)
label(tr,:,:) = repmat(c,1,size(sub_prob,2));
end
rho2 = permute(rho,[2 1 3]);
rho3 = rho2(:,:);
label2 = permute(label,[2 1 3]);
label3 = label2(:,:);

rho4 = [rho4 rho3];
label4 = [label4 label3];
end
end
plotroc(label4, rho4);
[tpr,fpr,thresholds] = roc(label4, rho4);
chance = [0 1];
figure,
plot([0 1], chance,'--r','LineWidth', 1, 'DisplayName', 'Random guess');
legend('-DynamicLegend');
hold all
marker = ['h','p','s','d'];
color = ['b','g','r','c'];
legends = {'Resting class', '13Hz class', '21Hz class', '17Hz class'};
for i = 1:numel(unique(Labels))
plot([fpr{i} 1], [tpr{i} 1], color(i), 'LineWidth', 2, 'MarkerSize',4, 'DisplayName', legends{i})
%legend('cl')
end
xlabel('FPR or (1-specificity)');
ylabel('TPR or sensitivity');
set(gca,'FontSize',14,'fontWeight','normal')
set(findall(gcf,'type','text'),'FontSize',14,'fontWeight','normal')

% %% COMPUTE AND PLOT ROC CURVE BASED ON RHO and DELTA
% clear all
% % load classProb
% load('./results/classProbGrad_4class.mat'); NbrSess = subNbrOfSess;
% Labels = Labels+1;
%
% rho4 = [];
% delta4 = [];
% label4 = [];
% for sub = 1:12
% sub_labels = Labels(:,:,1:NbrSess(sub),sub);
% sub_prob = classProb(:,:,:,1:NbrSess(sub),sub);
% sub_grad = classGrad(:,:,:,1:NbrSess(sub),sub);
% Lsub = [];
% rho = [];
% delta = [];
% label = [];
% for sess = 1:NbrSess(sub)
% for tr = 1:8*size(classProb,1)
% Lsub(tr,sess) = sub_labels(tr,1,sess);
% %rho(tr,:,sess) = sub_prob(:,:,tr,sess); %- Probability of groundtruth class (To be used as scrore in ROC)
% %label(tr,:,sess) = repmat(Lsub(tr,sess),1,numel(rho(tr,:,sess)));
%
% c = zeros(numel(unique(sub_labels)),1);
% c(Lsub(tr,sess)) = 1;
% rho(tr,:,:) = sub_prob(:,:,tr,sess); %- Probability of groundtruth class (To be used as scrore in ROC)
% delta(tr,:,:) = sub_grad(:,:,tr,sess); %- gradient of groundtruth class (To be used as scrore in ROC)
% label(tr,:,:) = repmat(c,1,size(sub_prob,2));
% end
% rho2 = permute(rho,[2 1 3]);
% rho3 = rho2(:,:);
% delta2 = permute(delta,[2 1 3]);
% delta3 = delta2(:,:);
% label2 = permute(label,[2 1 3]);
% label3 = label2(:,:);
%
% rho4 = [rho4 rho3];
% delta4 = [delta4 delta3];
% label4 = [label4 label3];
% end
% end
% plotroc(label4, rho4);
% plotroc(label4, delta4);
% [tpr,fpr,thresholds] = roc(label4, rho4);
% [tpr_d,fpr_d,thresholds_d] = roc(label4, delta4);
% chance = [0 1];
% figure,
% plot([0 1], chance,'--r','LineWidth', 1, 'DisplayName', 'Random guess');
% legend('-DynamicLegend');
% hold all
% marker = ['h','p','s','d'];
% color = ['b','g','r','c'];
% legends = {'Resting class', '13Hz class', '21Hz class', '17Hz class'};
% for i = 1:numel(unique(Labels))
% plot([fpr{i} 1], [tpr{i} 1], color(i), 'LineWidth', 2, 'MarkerSize',4, 'DisplayName', legends{i})
% %legend('cl')
% end
% xlabel('FPR or (1-specificity)');
% ylabel('TPR or sensitivity');
% set(gca,'FontSize',14,'fontWeight','normal')
% set(findall(gcf,'type','text'),'FontSize',14,'fontWeight','normal')
%
% figure,
% plot([0 1], chance,'--r','LineWidth', 1, 'DisplayName', 'Random guess');
% legend('-DynamicLegend');
% hold all
% marker = ['h','p','s','d'];
% color = ['b','g','r','c'];
% legends = {'Resting class', '13Hz class', '21Hz class', '17Hz class'};
% for i = 1:numel(unique(Labels))
% plot([fpr_d{i} 1], [tpr_d{i} 1], color(i), 'LineWidth', 2, 'MarkerSize',4, 'DisplayName', legends{i})
% %legend('cl')
% end
% xlabel('FPR or (1-specificity)');
% ylabel('TPR or sensitivity');
% set(gca,'FontSize',14,'fontWeight','normal')
% set(findall(gcf,'type','text'),'FontSize',14,'fontWeight','normal')




%% PLOT BARS
Y = [[70.8; 87.3; 87.7], [74.8; 79.1; 79.5]];
figure,
bar(Y)
%xlabel('FPR or (1-specificity)');
ylabel('Average classification accuracy (%)');
set(gca,'FontSize',14,'fontWeight','normal')
set(findall(gcf,'type','text'),'FontSize',14,'fontWeight','normal')
16 changes: 8 additions & 8 deletions tables.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
acNak = acSubMean*100;
itrNak = itr;
%-- Load MDRM Results
load offline_basic_potato_3class
load('./results/offline_basic_potato_3class.mat')
acMDRM = resMatrix(:,3,1)*100;
itrMDRM = itr;
%-- Loas MDRM opt. Results
load offline_opt_potato_3class
load('./results/offline_opt_potato_3class.mat')
acMDRMopt = resMatrix(:,3,1)*100;
itrMDRMopt = itr;

Expand Down Expand Up @@ -69,17 +69,17 @@

%% ONLINE RESULTS TABLE
%-- Load online cum results
load online_cum_3class
load('./results/online_cum_3class')
acCum = resMatrix(:,3)*100;
delCum = del_sub_all';
itrCum = itr';
%-- Load online cum+curve+potato
load online_curve_potato_3class.mat
load('./results/online_curve_potato_3class.mat')
acCur = resMatrix(:,3)*100;
delCur = del_sub_all';
itrCur = itr';
%-- Load online cum+curve+potato
load online_curve_3class.mat
load('./results/online_curve_3class.mat')
acCurPot = resMatrix(:,3)*100;
delCurPot = del_sub_all';
itrCurPot = itr';
Expand All @@ -103,17 +103,17 @@
%###################################################################################################################################
%% ONLINE RESULTS TABLE
%-- Load online cum results
load online_cum_4class
load('./results/online_cum_4class.mat')
acCum = resMatrix(:,3)*100;
delCum = del_sub_all';
itrCum = itr';
%-- Load online cum+curve+potato
load online_curve_4class.mat
load('./results/online_curve_4class.mat')
acCur = resMatrix(:,3)*100;
delCur = del_sub_all';
itrCur = itr';
%-- Load online cum+curve+potato
load online_curve_potato_4class.mat
load('./results/online_curve_potato_4class.mat')
acCurPot = resMatrix(:,3)*100;
delCurPot = del_sub_all';
itrCurPot = itr';
Expand Down

0 comments on commit 97e2f16

Please sign in to comment.