My Neural Net Pattern recognition confusion matrix result is 96% but when I add new input the output of net show always same result. I didn't understand why .
2 views (last 30 days)
Show older comments
Ali Zulfikaroglu on 11 Mar 2021
Commented: Ali Zulfikaroglu on 1 Apr 2021
This is my code .
End of code I add an input and get prediction of my net .
But net gives always same result.
I have three option [0;0] , [1;0], [1;1]
I get always [1;0].
What's my fault ?
% Solve a Pattern Recognition Problem with a Neural Network
% Script generated by Neural Pattern Recognition app
% Created 07-Feb-2021 15:50:44
% This script assumes these variables are defined:
% x - input data.
% t - target data.
% Choose a Training Function
% For a list of all training functions type: help nntrain
% 'trainlm' is usually fastest.
% 'trainbr' takes longer but may be better for challenging problems.
% 'trainscg' uses less memory. Suitable in low memory situations.
trainFcn = 'trainscg'; % Scaled conjugate gradient backpropagation.
% Create a Pattern Recognition Network
hiddenLayerSize = [5,4,3];
net = patternnet(hiddenLayerSize, trainFcn);
% Setup 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,x,t);
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y)
tind = vec2ind(t);
yind = vec2ind(y);
percentErrors = sum(tind ~= yind)/numel(tind);
% View the Network
% Uncomment these lines to enable various plots.
a=stats1'; % a is my input data inside stats1 matrix
outputs = round(sim(net,a))
% I always get output result [1;0] even I load input which I know the result [0;0]
% but it still show the result [1;0]
If neural network has issues with specific classes/outputs, then you should check if that specific class has very few samples in the dataset.
Also, wide datasets, where there are too many features, can be difficult to train on due to overfitting. Try reducing the number of features using dimensionality reduction techniques.
There could be other issues as well, like mislabelled data, the model being too large/small, etc. Try experimenting by changing one component at a time. For example, if some other model/algorithm works well on the data, you can rule out issues with data.
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!