Arranging the input and target matrix in Artificial neural network classification problem.
2 views (last 30 days)
Show older comments
debasmita bhoumik
on 15 Apr 2016
Commented: debasmita bhoumik
on 16 Apr 2016
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.
0 Comments
Accepted Answer
Greg Heath
on 16 Apr 2016
1. Please reformat your post so that the code will run when cut and pasted.
2. Assuming every thing else is OK, you need to have a good combination of H(No. of hidden nodes) and rng (RNG state that determines the initial random weights).
3. Search using the NEWSGROUP and ANSWERS using
greg patternnet
to see how I use a double loop approach to find the best combination.
4. However, in this case I think the answer is with I = 16, O = 2, N = 80 and H = 10 you have more unknown weights
Nw = (I+1)*H +(H+1)*O = 192
than training equations
Ntrneq = Ntrn*O = 0.7*N*O = 112.
Possible contributions to a remedy:
1. Increase N
2. Reduce H
3. Multiple random initial weight designs
4. Reduce I. The input rankings obtained from the linear models
STEPWISEFIT or PLSREGRESS might be useful.
5. Use MSEREG and/or TRAINBR
Hope this helps.
Thank you for formally accepting my answer
Greg
P.S. Let us know what happens.
2 Comments
More Answers (0)
See Also
Categories
Find more on Image Data Workflows 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!