Need help on neural network train test and validation accuracy
Afficher commentaires plus anciens
My data set have 420 images(24 features each). there are 160 for train. 20 for validation. 240 for testing. my problem is, after writing this code am getting 100% accuracy which is absurd. plz help me in this matter as am not sure if my code is correct or not.
% Solve a Pattern Recognition Problem with a Neural Network
load('ftrmat420.mat'); %420 x 24
load('class_test.mat'); %1 x 420
x=transpose(ftrmat420);
t=class_test;
inputs = x
targets = t
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% Set up Division of Data for Training, Validation, Testing
%net.divideParam.trainRatio = 30/100;
%net.divideParam.valRatio = 13/100;
%net.divideParam.testRatio = 57/100;
%[trainInd,valInd,testInd] = divideind(420,241:420,1:10,1:240);
net.divideFcn = 'divideind';
net.divideParam.trainInd = 261:420;
net.divideParam.valInd = 241:260;
net.divideParam.testInd = 1:240;
% Train the Network
[net,tr] = train(net,inputs,targets);
% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs)
performance = perform(net,targets,outputs)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
figure, plotperform(tr)
figure, plottrainstate(tr)
figure, plotconfusion(targets,outputs)
[c,cm] = confusion(targets,outputs)
fprintf('Percentage Correct Classification : %f%%\n', 100*(1-c));
fprintf('Percentage Incorrect Classification : %f%%\n', 100*c);
figure, ploterrhist(errors)
trainTargets = targets .* tr.trainMask{1};
valTargets = targets .* tr.valMask{1};
testTargets = targets .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Pattern Recognition dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!