You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
How to repeat c parameter(box constraint) using different value?
1 view (last 30 days)
Show older comments
example below, i need to repeat 1 with others number
SVMStruct = svmtrain(data(train,:),Y(train),'Kernel_Function','linear','BoxConstraint',1,'showplot',true);
Accepted Answer
Walter Roberson
on 11 Oct 2015
if islogical(train)
numtrain = sum(train);
else
numtrain = length(train);
end
bc = rand(1, numtrain); %data of the appropriate size
SVMStruct = svmtrain( data(train,:), Y(train), 'Kernel_Function', 'linear', 'BoxConstraint', bc, 'showplot', true);
12 Comments
Need Help
on 11 Oct 2015
Edited: Walter Roberson
on 11 Oct 2015
part of my program is like below that i need to add more values other than 1 next to the boxconstraint
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);
sorry for my bad english
Walter Roberson
on 11 Oct 2015
What you pass to BoxConstraint must be either a single value or else it must be a vector that has the same length as the number of samples you pass.
As I can see now that your train variable is logical, I can simplify what I posted above:
numtrain = sum(train);
Then
bc = rand(1, numtrain); %data of the appropriate size
Here, bc can be set to any vector that is of length numtrain . For example you could set
bc = ones(1, numtrain);
bc(3:3:end) = 4;
which would create the pattern [1 1 4 1 1 4 1 1 4 ...]
Then you pass this bc variable where you passed 1 before:
SVMStruct = svmtrain( data(train,:), Y(train), ...
'Kernel_Function', 'linear', ...
'BoxConstraint', bc, ... %NOTICE CHANGE
'showplot', true);
Need Help
on 12 Oct 2015
Edited: Walter Roberson
on 12 Oct 2015
sorry what i mean that i need to add more values for example like your above
bc = 1
bc = 2
bc = 5
bc = 10
bc = 20
bc = 50
bc =100
SVMStruct = svmtrain( data(train,:), Y(train), 'Kernel_Function', 'linear', 'BoxConstraint', bc, 'showplot', true);
from bc = 1 it will show only 1 result, but i need to get all result from bc above.
really hope you can help
Walter Roberson
on 12 Oct 2015
If you want to run the same training multiple times but with a different single bc value each time, then:
bcvals = [1 2 5 10 20 50 100];
for K = 1 : length(bcvals)
bc = bcvals(K);
SVMStruct{K} = svmtrain( data(train,:), Y(train), ...
'Kernel_Function', 'linear', ...
'BoxConstraint', bc, ...
'showplot', true);
end
This would return a cell array SVMStruct which has as many entries as the number of bc values you asked to process.
Need Help
on 12 Oct 2015
Edited: Walter Roberson
on 16 Oct 2015
i get 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.9767
ErrorRate: 0.0233
LastCorrectRate: 0.9767
LastErrorRate: 0.0233
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.9524
PositivePredictiveValue: 0.9565
NegativePredictiveValue: 1
PositiveLikelihood: 21
NegativeLikelihood: 0
Prevalence: 0.5116
DiagnosticTable: [2x2 double]
ans =
0.9767
conMat =
20 1
0 22
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.9767
ErrorRate: 0.0233
LastCorrectRate: 0.9767
LastErrorRate: 0.0233
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 0.9524
Specificity: 1
PositivePredictiveValue: 1
NegativePredictiveValue: 0.9565
PositiveLikelihood: NaN
NegativeLikelihood: 0.0476
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
ans =
0.9767
conMat =
22 0
1 20
>>
Need Help
on 16 Oct 2015
Hey, thanks . finally i get the answer from your solution.thank you very much. Can you help me a little bit more on how to get average of each answer above using array.
Walter Roberson
on 16 Oct 2015
I have no idea what output we are looking at. It appears to show several intermediate calculations from some unspecified code, without indicating which variables have been saved or what their values are.
Also, you have not specified what you want to get the average of.
Need Help
on 16 Oct 2015
Edited: Walter Roberson
on 16 Oct 2015
foldNo =
1
bc =
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]
Acc =
0.9762
Sen =
1
Spe =
0.9524
conMat =
20 1
0 21
bc =
2
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]
Acc =
0.9762
Sen =
1
Spe =
0.9524
conMat =
20 1
0 21
bc =
5
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]
Acc =
0.9762
Sen =
1
Spe =
0.9524
conMat =
20 1
0 21
bc =
10
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]
Acc =
0.9762
Sen =
1
Spe =
0.9524
conMat =
20 1
0 21
bc =
20
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]
Acc =
0.9762
Sen =
1
Spe =
0.9524
conMat =
20 1
0 21
bc =
50
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]
Acc =
0.9762
Sen =
1
Spe =
0.9524
conMat =
20 1
0 21
bc =
100
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]
Acc =
0.9762
Sen =
1
Spe =
0.9524
conMat =
20 1
0 21
foldNo =
2
bc =
1
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]
Acc =
0.9302
Sen =
1
Spe =
0.8636
conMat =
19 3
0 21
bc =
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.9070
ErrorRate: 0.0930
LastCorrectRate: 0.9070
LastErrorRate: 0.0930
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.8182
PositivePredictiveValue: 0.8400
NegativePredictiveValue: 1
PositiveLikelihood: 5.5000
NegativeLikelihood: 0
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
Acc =
0.9070
Sen =
1
Spe =
0.8182
conMat =
18 4
0 21
bc =
5
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.9070
ErrorRate: 0.0930
LastCorrectRate: 0.9070
LastErrorRate: 0.0930
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.8182
PositivePredictiveValue: 0.8400
NegativePredictiveValue: 1
PositiveLikelihood: 5.5000
NegativeLikelihood: 0
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
Acc =
0.9070
Sen =
1
Spe =
0.8182
conMat =
18 4
0 21
bc =
10
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.9070
ErrorRate: 0.0930
LastCorrectRate: 0.9070
LastErrorRate: 0.0930
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.8182
PositivePredictiveValue: 0.8400
NegativePredictiveValue: 1
PositiveLikelihood: 5.5000
NegativeLikelihood: 0
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
Acc =
0.9070
Sen =
1
Spe =
0.8182
conMat =
18 4
0 21
bc =
20
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.9070
ErrorRate: 0.0930
LastCorrectRate: 0.9070
LastErrorRate: 0.0930
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.8182
PositivePredictiveValue: 0.8400
NegativePredictiveValue: 1
PositiveLikelihood: 5.5000
NegativeLikelihood: 0
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
Acc =
0.9070
Sen =
1
Spe =
0.8182
conMat =
18 4
0 21
bc =
50
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.9070
ErrorRate: 0.0930
LastCorrectRate: 0.9070
LastErrorRate: 0.0930
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.8182
PositivePredictiveValue: 0.8400
NegativePredictiveValue: 1
PositiveLikelihood: 5.5000
NegativeLikelihood: 0
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
Acc =
0.9070
Sen =
1
Spe =
0.8182
conMat =
18 4
0 21
bc =
100
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.9070
ErrorRate: 0.0930
LastCorrectRate: 0.9070
LastErrorRate: 0.0930
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.8182
PositivePredictiveValue: 0.8400
NegativePredictiveValue: 1
PositiveLikelihood: 5.5000
NegativeLikelihood: 0
Prevalence: 0.4884
DiagnosticTable: [2x2 double]
Acc =
0.9070
Sen =
1
Spe =
0.8182
conMat =
18 4
0 21
foldNo =
3
bc =
1
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]
Acc =
0.9535
Sen =
0.9545
Spe =
0.9524
conMat =
20 1
1 21
bc =
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.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]
Acc =
0.9535
Sen =
0.9545
Spe =
0.9524
conMat =
20 1
1 21
bc =
5
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]
Acc =
0.9535
Sen =
0.9545
Spe =
0.9524
conMat =
20 1
1 21
bc =
10
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]
Acc =
0.9535
Sen =
0.9545
Spe =
0.9524
conMat =
20 1
1 21
bc =
20
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]
Acc =
0.9535
Sen =
0.9545
Spe =
0.9524
conMat =
20 1
1 21
bc =
50
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]
Acc =
0.9535
Sen =
0.9545
Spe =
0.9524
conMat =
20 1
1 21
bc =
100
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.9767
ErrorRate: 0.0233
LastCorrectRate: 0.9767
LastErrorRate: 0.0233
InconclusiveRate: 0
ClassifiedRate: 1
Sensitivity: 1
Specificity: 0.9524
PositivePredictiveValue: 0.9565
NegativePredictiveValue: 1
PositiveLikelihood: 21
NegativeLikelihood: 0
Prevalence: 0.5116
DiagnosticTable: [2x2 double]
Acc =
0.9767
Sen =
1
Spe =
0.9524
conMat =
20 1
0 22
>>
this is the output from bc=1,2,5,10,20,50 to bc=100 from kfold 1 to kfold 3
i need to use array to store and get average of the sensitivity, specificity and accuracy from the all k-fold
Walter Roberson
on 16 Oct 2015
You need to show your code, as I have no idea which routine is producing the output you are showing.
Need Help
on 16 Oct 2015
This is my code. hope can help.
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;
bcvals = [1 2 5 10 20 50 100];
for K = 1 : length(bcvals)
bc = bcvals(K)
SVMStruct{K} = svmtrain( data(train,:), Y(train), 'Kernel_Function', 'linear', 'BoxConstraint',bc, 'showplot', true);
%%
Group = svmclassify(SVMStruct{K},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)
Acc=cp.CorrectRate
Sen=cp.Sensitivity
Spe=cp.Specificity
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
end
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)