clear; close all; clc;
T = readtable('train.csv');
X = T(:,(1:562));
Y = T(:,{'Activity'});
t = templateSVM('Standardize',true,'SaveSupportVectors',true);
predictorNames = {'alfa','beta'};
responseName = 'Human Activity';
classNames = {'STANDING','SITTING','LAYING','WALKING','WALKING_DOWNSTAIRS','WALKING_UPSTAIRS'};
Mdl = fitcecoc(X,Y);
Mdl.ClassNames
Mdl.CodingMatrix
L = size(Mdl.CodingMatrix,6);
sv = cell(L,1);
for j = 1:L
SVM = Mdl.BinaryLearners{j};
sv{j} = SVM.SupportVectors;
sv{j} = sv{j}.*SVM.Sigma + SVM.Mu;
end
hold on
markers = {'ko','ko','ko','ko','ko','ko','ko'};
for j = 1:L
svs = sv{j};
plot(svs(:,1),svs(:,2),markers{j},...
'MarkerSize',10 + (j - 1)*3);
end
title('Fisher''s Iris -- ECOC Support Vectors')
xlabel(predictorNames{1})
ylabel(predictorNames{2})
legend([classNames,{'Support vectors - SVM 1',...
'Support vectors - SVM 2','Support vectors - SVM 3'}],...
'Location','Best')
hold off