-
Notifications
You must be signed in to change notification settings - Fork 1
/
findError.m
48 lines (41 loc) · 1.52 KB
/
findError.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function [avgError,minError,maxError,sdError] = findError(A,B,J,K,discriminants,true_n_ab,true_n_ba)
for j=1:J
totalError = [];
for k=1:K
dataA = A;
dataB = B;
lenA = size(A,1);
lenB = size(B,1);
classA = zeros(size(A,1),1);
classB = zeros(size(B,1),1);
errorRate = 0;
% Get classifiers
[discriminants,true_n_ab,true_n_ba] = sequentialClassifier(dataA,dataB,J);
% Check each point in dataset A
for i=1:lenA
x = A(i,:);
classA(i) = classifyClasses(J,x(1),x(2),discriminants,true_n_ab,true_n_ba);
% Misclassified
if (classA(i) == 2)
errorRate = errorRate + 1;
end
end
% Check each point in dataset B
for i=1:lenB
x = B(i,:);
classB(i) = classifyClasses(J,x(1),x(2),discriminants,true_n_ab,true_n_ba);
% Misclassified
if (classB(i) == 1)
errorRate = errorRate + 1;
end
end
% Calculate the total error:
totalError(k) = errorRate/400;
end
% Calculate the various error rates:
avgError(j) = mean(totalError);
minError(j) = min(totalError);
maxError(j) = max(totalError);
sdError(j) = std2(totalError);
end
end