-
Notifications
You must be signed in to change notification settings - Fork 1
/
cAccOutter.m
35 lines (28 loc) · 1.14 KB
/
cAccOutter.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
% Programmed by Javad Rahimipour Anaraki on 29/05/18
% Ph.D. Candidate
% Department of Computer Science
% Memorial University of Newfoundland
% jra066 [AT] mun [DOT] ca | www.cs.mun.ca/~jra066
% Programmed by Hamid Usefi
% Associate Professor of Mathematics
% Department of Mathematics and Statistics
% Memorial University of Newfoundland
% usefi [AT] mun [DOT] ca | www.math.mun.ca/~usefi/
% Input: Selected features
% Output: Classification accuracy using Decision Tree classifier
function clsOut = cAccOutter(selF)
%%================================Data=====================================
global data;
[r, ~] = size(data);
trainSize = floor(.7 * r);
train = data(1:trainSize, selF);
test = data(trainSize+1:end, selF);
nClass = length(unique(data(:, end)));
%%============================Decision Tree================================
Model = fitctree(train(:, 1:end-1), train(:, end));
predicted = predict(Model, test(:, 1:end-1));
%%========================Classification Accuracy==========================
C = confusionmat(test(:, end), predicted);
term = diag(C) ./ sum(C, 2);
clsOut = 1/nClass * sum(term) * 100;
return