Nano'nun Günlüğü…

Ideallerimi gerceklestirmek icin arastiriyorum, Unutmamak icin yaziyorum!

  • Bulundugunuz Sayfa: 
  • Ana Sayfa
  • Pattern Recognition Assignments I

Pattern Recognition Assignments I

Gönderim Haziran 26th, 2014

patregPattern Recognition – Oruntu Tanima alaninda calismaniz icin Mean Vector, Covariance Matrix, Med – minimum euclid distance, ozdeger, oz vektor ve standart sapma konulari ornek niteliginde isinize yarayabilecek soru ve cevaplari bu makale iceriginde bulabilirsiniz.

Assignment I

QA1 ) (2,1), (3,2), (2,3), (1,2) degerleri verilmistir. Mean Vector M ve Covariance Matrix S ‘i hesaplayalim.

Matlab Kodu;
clear all;
close all;
clc;

X = [2,1; 3,2; 2,3; 1,2]
meanVectorM = mean(X,1)   % 1 dimension
meanVectorM2 = mean(X,2)  % 2 dimension
covarianceMatrixS = cov(X)

nokta = [2,3,2,1; 1,2,3,2];
figure; plot(nokta(1,:),nokta(2,:),’*r’);
axis([0 10 0 10]);
grid on;

Cozum;
X =     [2     1
3     2
2     3
1     2]

meanVectorM =   [ 2     2 ]

meanVectorM2 =  [   1.5000
2.5000
2.5000
1.5000  ]

covarianceMatrixS =  [ 0.6667         0
0    0.6667]

Assignment II

QA2 ) iki adet training set olusturup bunlari MED yani minimum euclid distance uzerinde hesaplanmasi;

Matlab Kodu;

clear all; close all; clc;

X = [80,70,50,90,85;]’
Y = [85,60,70,70,75;]’

MEDistance  = sqrt(sum((X – Y) .^ 2))

nokta1 = [80,70,50,90,85; ];
nokta2 = [85,60,70,70,75;];
figure; plot(nokta1(1,:),’*r’);
hold on;
plot(nokta2(1,:),’*b’);
axis([40 100 40 100]);
axis equal;
grid on;

Cozum;
X =            80
70
50
90
85
Y =          85
60
70
70
75
MEDistance =   32.0156

Assignment III

QA3 ) (2,1) (1,2) degerleri verilmistir. Ozdeger ve oz vektorleri bulunacaktir. Standart sapmasi nedir?

Matlab Kodu;

clear all;
close all;
clc;

% oz cozumleri bulmak icin
% A*v = Lambda*V => A*v – Lambda*V = 0 => (A – Lambda)*V = 0

A = [2,1;1,2;]
v = [0,0]’

lamba1 = 1/2 * ( [A(1,1) + A(2,2)] + sqrt( [A(1,1) – A(2,2)]^2 + 4 * (A(1,2)^2) )   )
lamba2 = 1/2 * ( [A(1,1) + A(2,2)] – sqrt( [A(1,1) – A(2,2)]^2 + 4 * (A(1,2)^2) )   )

I = eye(2) % oz deger hesaplanmasi icin birim matris olusturulur.
eigenValue1 = A – lamba1 * I
eigenValue2 = A – lamba2 * I

v1 = eigenValue1(1,1) + eigenValue1(2,2)
% eigenValue1(1,1) + eigenValue1(2,2) = trace(eigenValue1)
v2 = eigenValue2(1,1) + eigenValue2(2,2)
% eigenValue2(1,1) + eigenValue2(2,2) = trace(eigenValue2)

eigenVector = [v1,v2]’   % oz vektor hesaplanir
standardDeviation = std(eigenVector) % standart sapma hesaplanir

Cozum;
A =     2     1
1     2
v =      0
0
lamba1 =     3
lamba2 =     1
I =     1     0
0     1
eigenValue1 =   -1     1
1    -1
eigenValue2 =    1     1
1     1
v1 =    -2
v2 =     2
eigenVector =    -2
2
standardDeviation =    2.8284

Assignment IV

QA4 ) Standart sapmanin bulundugu alan hesaplanir.

Matlab Kodu;

clear all;
close all;
clc;

X = [3/5,-4/5; 4/5,3/5]
meanVectorM = mean(X,1)   % 1 dimension
meanVectorM2 = mean(X,2)  % 2 dimension

medyan = median(X)
covarianceMatrixS = cov(X)
standartSapma = std(X)

nokta = [3/5,4/5; -4/5,3/5];
figure; plot(nokta(1,:),nokta(2,:),’*r’);
axis([-1 1 -1 1]);
axis equal;
grid on;

Cozum;

X =    0.6000   -0.8000
0.8000    0.6000
meanVectorM =    0.7000   -0.1000
meanVectorM2 =    -0.1000
0.7000
medyan =    0.7000   -0.1000
covarianceMatrixS =     0.0200    0.1400
0.1400    0.9800
standartSapma =    0.1414    0.9899

Assignment V

QA5 ) Ci: (2,2) (4,0) (10,2) (8,4) (8,0) (4,4) ve Cj: (4,10) (8,18) (8,10) (6,6) (4,18) (6,22) training set verilmistir. grafik uzerinde noktalar gosterilip, med ve nn classification uygulanip, gelen yeni noktanin nereye ait oldugu belirlenmistir.

Matlab Kodu;

clear all;
close all;
clc;

X1 = [2,2; 4,0; 10,2; 8,4; 8,0; 4,4]
X2 = [4,10; 8,18; 8,10; 6,6; 4,18; 6,22]

noktaX1 = [2,4,10,8,8,4; 2,0,2,4,0,4,];
noktaX2 = [4,8,8,6,4,6; 10,18,10,6,18,22];
figure;
plot(noktaX1(1,:),noktaX1(2,:),’*r’);
hold on;
plot(noktaX2(1,:),noktaX2(2,:),’*b’);
axis([-5 10 -7 30]);
axis equal;
grid on;

%%%%%%%% A sikki %%%%%%%%%
meanVectorM1 = mean(X1,1)   % 1 dimension
meanVectorM12 = mean(X1,2)  % 2 dimension
covarianceMatrixS1 = cov(X1)

meanVectorM2 = mean(X2,1)   % 1 dimension
meanVectorM22 = mean(X2,2)  % 2 dimension
covarianceMatrixS2 = cov(X2)

%%%%%%%% B sikki %%%%%%%%%

%% iki vektorun MED yani oklit uzakliklarini hesaplariz
MED = distance(X1,X2)

%%%%%%%% C sikki %%%%%%%%%

% gelen yeni degeri her iki matristede yerini belirleriz.
prototype = [7,6]

for i=1:length(X1)
sonuc(i,:) = [(prototype(1,1) – X1(i,1))^2  + (prototype(1,2) – X1(i,2))^2];
end

NNMatrixX1 = sonuc(:,:)
vektorAraligi1 = min(NNMatrixX1)

for i=1:length(X2)
sonuc(i,:) = [(prototype(1,1) – X2(i,1))^2  + (prototype(1,2) – X2(i,2))^2];
end

NNMatrixX2 = sonuc(:,:)
vektorAraligi2 = min(NNMatrixX2)

%%%%%%%% D sikki %%%%%%%%%

hold on;
prototypeNokta = [7; 6];
plot(prototypeNokta(1,:),prototypeNokta(2,:),’Or’);

Cozum;
X1 =       2     2
4     0
10     2
8     4
8     0
4     4
X2 =       4    10
8    18
8    10
6     6
4    18
6    22

meanVectorM1 =     6     2
meanVectorM12 =          2
2
6
6
4
4

covarianceMatrixS1 =
9.6000         0
0        3.2000

meanVectorM2 =     6    14

meanVectorM22 =           7
13
9
6
11
14

covarianceMatrixS2 =       3.2000         0
0        38.4000
MED =      8.2352
18.3384
8.1501
2.8178
18.3384
18.0412
prototype =     7     6
NNMatrixX1 =        41
45
25
5
37
13
vektorAraligi1 =     5         (4. satir)
NNMatrixX2 =       25
145
17
1
153
257
vektorAraligi2 =     1           (4. satir)

Yeni gelen (7,6) noktasi her ikisinde 4.satir’a ait yerlerde bulunmaktadir. Ayni zamanda sekilde de O sekli ile hangi alana ait oldugu gosterilmektedir.

Keyifli Calismalar Dilerim.

Etiketler: , , , , , , , , , ,
Bulundugu Konu Etiketleri Akademik, Matlab, Oruntu Tanima/ Pattern Recognition, Yazilim |

Lutfen Yorumlarinizi Burdan Ulastiriniz!...

You must be Kullanici Adiniz : to post a comment.

Istatistik

  • 1 Uye
  • 334 Yazi
  • 16 Yorum Var