-
Notifications
You must be signed in to change notification settings - Fork 21
/
mainFCT.m
148 lines (112 loc) · 6.53 KB
/
mainFCT.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
load('data.mat')
addpath('.//KEDcode')
addpath('.//SVM')
addpath('.//GMM')
X_Train = data.Xtrain'; %750*NoF 750 samples,NoF features
Y_Train = data.Ytrain; %750*1 750 samples,target=1..15 (15 classes)
X_Test = data.Xval'; %12197*NoF
Y_Test_Desired = data.Yval; %the desire output of target(class value)
%down sample for testing data: select a designated sample per
%class-------------------
Dim=14;K=2;
%
% %FeatureReductor='LDA'; %Dim<15
% %FeatureReductor='PCA';
% %FeatureReductor='KLDA'; %Dim<15
% %FeatureReductor='KPCA';
% %FeatureReductor='NONE';
%
% %Classifier='GaussianML';
% %Classifier='KNN';
% %Classifier='GMM';
% %Classifier='KSVM';
FeatureReductor='PCA';Classifier='GaussianML';
Accuracy(1,1) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='PCA';Classifier='GMM';
Accuracy(2,1) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='PCA';Classifier='KNN';
Accuracy(3,1) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='PCA';Classifier='KSVM';
Accuracy(4,1) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='GaussianML';
Accuracy(1,2) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='GMM';
Accuracy(2,2) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='KNN';
Accuracy(3,2) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='KSVM';
Accuracy(4,2) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='GaussianML';
Accuracy(1,3) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='GMM';
Accuracy(2,3) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='KNN';
Accuracy(3,3) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='KSVM';
Accuracy(4,3) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='GaussianML';
Accuracy(1,4) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='GMM';
Accuracy(2,4) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='KNN';
Accuracy(3,4) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='KSVM';
Accuracy(4,4) = PatternRecog(X_Train,Y_Train,X_Test,Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
Accuracy_downsample_Matrix(:,:,1)=Accuracy;
Accuracy_downsample_Vector(1,:)=Accuracy(:);
% change the size of training dataset:----------------------------------------
i=1;
for NoS=[10,20,30]
i=i+1;
[DS_X_Test,DS_Y_Test_Desired]= downsample(X_Test,Y_Test_Desired,NoS);
FeatureReductor='PCA';Classifier='GaussianML';
Accuracy(1,1) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='PCA';Classifier='GMM';
Accuracy(2,1) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='PCA';Classifier='KNN';
Accuracy(3,1) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='PCA';Classifier='KSVM';
Accuracy(4,1) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='GaussianML';
Accuracy(1,2) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='GMM';
Accuracy(2,2) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='KNN';
Accuracy(3,2) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KPCA';Classifier='KSVM';
Accuracy(4,2) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='GaussianML';
Accuracy(1,3) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='GMM';
Accuracy(2,3) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='KNN';
Accuracy(3,3) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='LDA';Classifier='KSVM';
Accuracy(4,3) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='GaussianML';
Accuracy(1,4) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='GMM';
Accuracy(2,4) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='KNN';
Accuracy(3,4) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
FeatureReductor='KLDA';Classifier='KSVM';
Accuracy(4,4) = PatternRecog(X_Train,Y_Train,DS_X_Test,DS_Y_Test_Desired,FeatureReductor,Dim,Classifier,K);
Accuracy_downsample_Matrix(:,:,i)=Accuracy;
Accuracy_downsample_Vector(i,:)=Accuracy(:);
end
%%
%---------------choose a Feature reduction method:
%FeatureReductor='LDA'; %Dim<15
%FeatureReductor='PCA';
%FeatureReductor='KLDA'; %Dim<15
%FeatureReductor='KPCA';
%FeatureReductor='NONE';
%Parameter:Dim
%Dim=14;
%[X_Train_Proj,X_Test_Proj]=FeatureReduction(X_Train,Y_Train,X_Test,FeatureReductor,Dim);
%%
%feature Classification:----------------choose a Classifier:
targets=ind2vec(Y_Test_Desired');
outputs=ind2vec(Y_Test');
plotconfusion(targets,outputs);
plotroc(targets,outputs);