In this activity, we apply a different method to classify objects into groups. In the previous activity, mean distance classification was used. Here, we employ probabilistic classification via Linear Discriminant Analysis (LDA). A detailed discussion on the method and equations used can be viewed from Pattern_Recognition_2.pdf by Dr. S. Marcos. We use two classes of objects from the previous activity and see whether this method classifies them correctly or not.
Kwekkwek and Pillows
Also shown below are the values for length/height, R, G, B for each object.
Again, we separate the 8 objects per class into a test set and a training set. The training set is given below. From here the method is implemented and the code and results are also shown below.//this code just follows the procedure described in Pattern_Recognition_2.pdf
x = [0.97 0.74 0.37 0.03;
1.00 0.77 0.42 0.03;
0.96 0.73 0.38 0.03;
0.91 0.74 0.38 0.06;
0.96 0.30 0.16 0.07;
1.00 0.30 0.16 0.07;
1.02 0.33 0.18 0.08;
1.02 0.33 0.19 0.09];
y = [1 1 1 1 2 2 2 2]';
g = 2;
x1 = x(1:4,:);
x2 = x(5:8,:);
u1 = [mean(x1(:,1)) mean(x1(:,2)) mean(x1(:,3)) mean(x1(:,4))];
u2 = [mean(x2(:,1)) mean(x2(:,2)) mean(x2(:,3)) mean(x2(:,4))];
u = [mean(x(:,1)) mean(x(:,2)) mean(x(:,3)) mean(x(:,4))];
x1_o = [x1(1,:)-u; x1(2,:)-u; x1(3,:)-u; x1(4,:)-u];
x2_o = [x2(1,:)-u; x2(2,:)-u; x2(3,:)-u; x2(4,:)-u];
n1 = 4; n2 = n1;
c1 = (x1_o'*x1_o)/n1;
c2 = (x2_o'*x2_o)/n2;
for r = 1:4
for s = 1:4
C(r,s) = (4/8)*(c1(r,s)+c2(r,s));
end
end
Cinv = inv(C);
p = [4/8; 4/8];
for k = 1:8
f1(k) = u1*Cinv*x(k,:)' - 0.5*u1*Cinv*u1' + log(p(1));
f2(k) = u2*Cinv*x(k,:)' - 0.5*u2*Cinv*u2' + log(p(2));
end
____________________________________________________________________
RESULTS:
From the table above, we can see that this method resulted in a 100% correct classification for the training set. The higher value of f will determine which group the object is classified under. We implement this on the test set and see what happens.
Again, a 100% correct classification is obtained. We have illustrated the success of this method in classifying objects into groups.____________________________________________________________________
I give myself 10 points for this activity since the method was implemented correctly and there is 0% error.
0 comments:
Post a Comment