How to make multiple output from SVMStruct = [ svmtrain(d​ata(train,​:),Y(train​),'Kernel_​Function',​'linear','​BoxConstra​int',1,'sh​owplot',tr​ue); ] for example i need more than 1 input after the boxconstraint

4 views (last 30 days)
clear all, close all, clc
%%LOAD SALIVA DATA (ROI_nobase)
myfile=uigetfile('*.mat','MAT-files (*.mat)');
my_data=load(myfile);
mixture = struct2cell (my_data);
mixture = cell2mat (mixture);
%%LOAD MIXTURE DATA (ROI_nobase1)
myfile=uigetfile('*.mat','MAT-files (*.mat)');
my_data=load(myfile);
saliva = struct2cell (my_data);
saliva = cell2mat (saliva);
spot = input('insert no of PC=')
N=size(saliva,1);
N1=size(mixture,1);
data=[saliva(:,1:spot);mixture(:,1:spot)];
% data=[saliva;mixture];
Ndata=size(data,1);
labelsaliva={'saliva'};labelmix={'mixture'};
Y=nominal([repmat(labelsaliva,N,1);repmat(labelmix,N1,1)]);
K = input('insert K-fold=')
indices = crossvalind('Kfold',Y,K);
for i = 1:K
figure
foldNo=i
test = (indices == i);
train = ~test;
SVMStruct = svmtrain(data(train,:),Y(train),'Kernel_Function','linear','BoxConstraint',1,'showplot',true);
Group = svmclassify(SVMStruct,data(test,:),'showplot', true);
hold off;
grp1=Y(test);
testset=data(test,:);
hold on
mydiff = (Group == grp1(:,1)); % classified correctly
for j = mydiff
plot ( testset (j ,1) , testset (j ,2) ,'ro ', 'MarkerSize' ,15)
end
for j = not( mydiff ) % check plot black circles misclass
plot ( testset (j ,1) , testset (j ,2) ,'bo ', 'MarkerSize' ,15)
end
hold off;
cp = classperf(grp1);
classperf(cp,Group)
cp.CorrectRate
hold off;
conMat = confusionmat(grp1,Group)
hold on;
% Group = double(Group);
% [X1,Y1,T,AUC] = perfcurve(Y(test),Group,'saliva');
% plot(X1,Y1)
% xlabel('False positive rate'); ylabel('True positive rate')
% title('ROC for classification by SVM')
% Group = nominal(Group)
end
%
and the answer that i need will be more than 1 (KFOLD) like this
insert no of PC=2
spot =
2
insert K-fold=3
K =
3
foldNo =
1
Label: ''
Description: ''
ClassLabels: {2x1 cell}
GroundTruth: [42x1 double]
NumberOfObservations: 42
ControlClasses: 2
TargetClasses: 1
ValidationCounter: 1
SampleDistribution: [42x1 double]
ErrorDistribution: [42x1 double]
SampleDistributionByClass: [2x1 double]
ErrorDistributionByClass: [2x1 double]
CountingMatrix: [3x2 double]
CorrectRate: 0.9762
ErrorRate: 0.0238
LastCorrectRate: 0.9762
LastErrorRate: 0.0238
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.9524
PositivePredictiveValue: 0.9545
NegativePredictiveValue: 1
PositiveLikelihood: 21
NegativeLikelihood: 0
Prevalence: 0.5000
DiagnosticTable: [2x2 double]
ans =
0.9762
conMat =
20 1
0 21
foldNo =
2
Label: ''
Description: ''
ClassLabels: {2x1 cell}
GroundTruth: [43x1 double]
NumberOfObservations: 43
ControlClasses: 2
TargetClasses: 1
ValidationCounter: 1
SampleDistribution: [43x1 double]
ErrorDistribution: [43x1 double]
SampleDistributionByClass: [2x1 double]
ErrorDistributionByClass: [2x1 double]
CountingMatrix: [3x2 double]
CorrectRate: 0.9302
ErrorRate: 0.0698
LastCorrectRate: 0.9302
LastErrorRate: 0.0698
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.8636
PositivePredictiveValue: 0.8750
NegativePredictiveValue: 1
PositiveLikelihood: 7.3333
NegativeLikelihood: 0
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
ans =
0.9302
conMat =
19 3
0 21
foldNo =
3
Label: ''
Description: ''
ClassLabels: {2x1 cell}
GroundTruth: [43x1 double]
NumberOfObservations: 43
ControlClasses: 2
TargetClasses: 1
ValidationCounter: 1
SampleDistribution: [43x1 double]
ErrorDistribution: [43x1 double]
SampleDistributionByClass: [2x1 double]
ErrorDistributionByClass: [2x1 double]
CountingMatrix: [3x2 double]
CorrectRate: 0.9535
ErrorRate: 0.0465
LastCorrectRate: 0.9535
LastErrorRate: 0.0465
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 0.9545
Specificity: 0.9524
PositivePredictiveValue: 0.9545
NegativePredictiveValue: 0.9524
PositiveLikelihood: 20.0455
NegativeLikelihood: 0.0477
Prevalence: 0.5116
DiagnosticTable: [2x2 double]
ans =
0.9535
conMat =
20 1
1 21
>>

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!