why my models testing accuracy gets worse

2 views (last 30 days)
uma
uma on 23 Jun 2022
I have written my code below and dataset is also attached. After applyng the 10 fold cross-validation, the testing accuracy gets worse while there is no problem in training accuracy. Please help me to resovle this issue.
data1=xlsread('waveform.csv');
data=data1(:,1:end);
groups=data1(:,end);
Fold=10;
indices = crossvalind('Kfold',length(groups),Fold); % create indices of 10 fold cross-validation, Group is the vector containing the class label for each obsevation
for i =1:Fold % create train and test sets
display(['cross validation, folds' num2str(i)])
testy = (indices == i);
trainy = (~testy);
TrainInputData=data(trainy,:);
TrainOutputData=groups(trainy,:);
TestInputData=data(testy,:);
TestOutputData=groups(testy,:);
%
% set the parameters
%
% regularization parameter: [C1, C2, C3] for each layer respectively
% kernel parameters: [SIG1, SIG2, SIG3] for each layer respectively
C1 = 1; C2 = 1; C3 = 1;
SIG1 = 1; SIG2 = 1; SIG3 = 1;
[TrainingTime, TestingTime, TrainingAccuracy, TestingAccuracy] = ...
MLKELM([TrainInputData TrainOutputData], [TestInputData TestOutputData], 1, [C1, C2, C3], 'RBF_kernel', [SIG1, SIG2, SIG3], 3)
testing_Accuracy_f(i)=TestingAccuracy;% keep testing acc for each fold
end
mean=sum(testing_Accuracy_f)/length(testing_Accuracy_f);
StandDevx = sqrt(sum((testing_Accuracy_f-mean).^2)/(length(testing_Accuracy_f)-1));

Answers (0)

Categories

Find more on Test Model Components in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!