-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfusion.m
48 lines (48 loc) · 2.5 KB
/
fusion.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
function [ acc, Pred ]=fusion(classifiers, data)
X = data(:, 1:end-1);
Y = data(:, end);
decisionMatrix = ones(size(X,1), length(classifiers));
index = 1;
for i=1:length(classifiers)
try
if strcmp(classifiers{1,i}.name, 'SVM') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'KNN') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'DT') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'NB') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'DISCR') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'ANN') == 1
decisionMatrix(:,index) = getNNPredict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'NN') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'GAM') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'GLR') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'RBFNN') == 1
decisionMatrix(:,index) = getNNPredict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'BAG') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'SUBSPACE') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'TOTALBOOST') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'ADABOOST') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
elseif strcmp(classifiers{1,i}.name, 'LPBOOST') == 1
decisionMatrix(:,index) = predict(classifiers{1,i}.model, X);
end
index = index + 1;
catch ME
disp(sprintf('fusion causing errors: %s',ME.identifier));
end
end
Pred = decisionMatrix;
allCombined = mode(decisionMatrix,2);
acc = mean(allCombined == Y);
% [Xfpr,Ytpr,~,auc] = perfcurve(double(Y), double(allCombined), '1','TVals','all','xCrit', 'fpr', 'yCrit', 'tpr');
end