Arranging the input and target matrix in Artificial neural network classification problem.
Show older comments
Hello, I am using matlab for 6 months, so considering myself as a beginner, please help me in this. My goal is to classify a feature matrix consisting 16 features 80 images of leaf(1st 40 affected, next 40 normal) each. so the matrix size is 16x80. the name of that matrix is feature_trans. As I understand it will be the input matrix. Now I made the target matrix. It is a 2x80 matrix, where from index 1-40, row 1 = 0, row 2=1. and from index 40-80, row 1 = 1, row 2 = 0 (As I mentioned 1st 40 affected, next 40 normal ) and the name of that matrix is Target1. I have studied one example from mathworks and just replaced cancerInputs with feature_trans and cancerTargets with Target1. the original code i have used is from http://in.mathworks.com/help/nnet/gs/classify-patterns-with-a-neural-network.html
My code:
if true
% code
end
% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by NPRTOOL
%
% This script assumes these variables are defined:
%
% cancerInputs - input data.
% cancerTargets - target data.
inputs = feature_trans;
targets = Target1;
% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);
% Set up Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;
% 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)
figure, ploterrhist(errors)
********************************************
But the accuracy is 52%. But i have tested the same data with SVM CLASSIFIER and i got 96% accuracy. I couldnot understand where the loophole is. Please help me in this matter.
Accepted Answer
More Answers (0)
Categories
Find more on Pattern Recognition 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!