function [accuracy,clipVsPlot,withinClip,withinPlot,inTrain, ...
notInTrain,longerClips,confMat] = computeError(predictions);
% This file is part of the data release for the ICANN/PASCAL2
% Challenge on MEG mind reading, and was written by Arto Klami.
% See http://www.cis.hut.fi/icann2011/mindreading.php for more
% information.
%
% Input:
% - a column vector of predicted labels for the test samples
%
% Output:
% - accuracy: The ratio of correct predictions
% - clipVsPlot: Accuracy in the binary task of separating the clips
% from the films with plot
% - withinClip: Accuracy for recognizing the clips
% - withinPlot: Accuracy for recognizing the films
% - inTrain: Accuracy for samples from stimulus shown also during
% training
% - notInTrain: Accuracy for new stimuli
% - longerClips: Accuracy on full clips (or 8 consecutive samples)
% - confMat: Confusion matrix, predictions as rows and true classes
% as columns
%
% Read in the necessary information
load('testClassData.mat');
% Prediction accuracy
accuracy = length(find(predictions==class_test_day2))/length(class_test_day2);
% Compute the confusion matrix
confMat = crosstab(predictions,class_test_day2);
% Accuracies for the alternative tasks
clipVsPlot = (sum(sum(confMat(1:3,1:3))) + sum(sum(confMat(4:5,4: ...
5))))/length(class_test_day2);
ind = find(class_test_day2<4 & predictions<4);
withinClip = length(find(class_test_day2(ind)==predictions(ind))) ...
/ length(ind);
ind = find(class_test_day2>3 & predictions>3);
withinPlot = length(find(class_test_day2(ind)==predictions(ind))) / ...
length(ind);
% Accuracy for samples within train and outside of it
ind = find(detailedTest(:,3));
inTrain = length(find(predictions(ind)==class_test_day2(ind)))/ ...
length(ind);
ind = find(~detailedTest(:,3));
notInTrain = length(find(predictions(ind)==class_test_day2(ind)))/ ...
length(ind);
% Accuracy of making predictions based on all consecutive samples
% of the same stimulus category (for short clips) or 8 consecutive
% samples (for the longer films)
% Re-order the samples into chronological order
ind = find(detailedTest(:,1)==6);
[foo,temp] = sort(detailedTest(ind,2)); order = ind(temp);
ind = find(detailedTest(:,1)==7);
[foo,temp] = sort(detailedTest(ind,2)); order = [order;ind(temp)];
ind = find(detailedTest(:,1)==8);
[foo,temp] = sort(detailedTest(ind,2)); order = [order;ind(temp)];
% Go through the clips one by one, estimating the prediction for
% the whole clip
i = 1; n = 1;
acc = 0;
trueClass = [];
while(i