-
Notifications
You must be signed in to change notification settings - Fork 0
/
Function_set.m
72 lines (63 loc) · 1.89 KB
/
Function_set.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
% load data
for i = 1:11
if (i == 1)
load classify_d3_k2_saved1.mat;
elseif (i == 2)
load classify_d3_k2_saved2.mat;
elseif (i == 3)
load classify_d3_k2_saved3.mat;
elseif (i == 4)
load classify_d4_k3_saved1.mat;
elseif (i == 5)
load classify_d4_k3_saved2.mat;
elseif (i == 6)
load classify_d5_k3_saved1.mat;
elseif (i == 7)
load classify_d5_k3_saved2.mat;
elseif (i == 8)
load classify_d99_k50_saved1.mat;
elseif (i == 9)
load classify_d99_k50_saved2.mat;
elseif(i == 10)
load classify_d99_k60_saved1.mat;
else
load classify_d99_k60_saved2.mat;
end
%splitting dataset
[U, V] = size(class_1);
data_set1 = class_1(1:U, 1:0.8*V);
data_set2 = class_2(1:U, 1:0.8*V);
for j1=1:(0.8*V)
data_set1(1+U,j1) = 1;
end
for k1=1:(0.8*V)
data_set2(1+U,k1) = 2;
end
training_set = [data_set1,data_set2];
training_set = training_set';
data_set3 = class_1(1:U,((0.8*V)+1):V);
data_set4 = class_2(1:U,((0.8*V)+1):V);
for j2=1:(0.2*V)
data_set3(1+U,j2) = 1;
end
for k2=1:(0.2*V)
data_set4(1+U,k2) = 2;
end
testing_set = [data_set3, data_set4];
testing_set = testing_set';
%patterns to be trained
train_patterns = training_set(:,1:(size(training_set,2)-1));
train_targets = training_set(:,size(training_set,2))';
test_patterns=testing_set(:,1:(size(testing_set,2)-1));
test_targets=testing_set(:,size(testing_set,2))';
test_targets_predict = classifier(train_patterns', train_targets, test_patterns', 5, 10);
%calculating the accuracy of the model
temp_count=0;
for i1=1:size(test_targets_predict,2)
if test_targets(:,i1)==test_targets_predict(:,i1)
temp_count=temp_count+1;
end
end
accuracy=temp_count/size(test_targets,2);
disp(accuracy);
end