Clear Filters
Clear Filters

why the prediction of neural network is wrong?

4 views (last 30 days)
Hi
I have a matrix of input data (1X1006) and a 1X1006 target matrix. I trained the network and it gave me the regression line with R=0.98 and performance of 9.48E-10. I saved the trained network and used it for a new set of data to predict the target, but it gave me a negative number. I did not have any negative number in target when network was being trained. the new input is also a number completely in the range of my first input. I also need to mention that the range of input is between 0.002 to 7000 and the range of target is 0.00005 to 0.02. what is wrong ? Thanks
x=xlsread('input.xlsx');
t=xlsread('target.xlsx');
net = fitnet(10);
[net,tr] = train(net,x,t);
y=net(x);
nntraintool
farnet=net;
save farnet
testX = x(:,tr.testInd);
testT = t(:,tr.testInd);
testY = net(testX);
perf = mse(net,testT,testY)
figure
e = t - y;
ploterrhist(e)
hold on
figure
y = net(x);
plotregression(t,y)
load farnet
newinput=xlsread('newinput.xlsx');
newoutput = farnet(newinput)

Accepted Answer

Greg Heath
Greg Heath on 26 Jul 2018
1.There is nothing in your design to prevent negative outputs.
2. Therefore the question is
What are the ranks of the ABSOLUTE VALUES of the negative
output errors?
3. If this still bothers you, use a nonnegative output function.
Hope this helps.
Thank you for formally accepting my answer
Greg
  2 Comments
farfar
farfar on 26 Jul 2018
Edited: farfar on 26 Jul 2018
Thank you. No i did not define a function to prevent negative output. but should not the output be based on 1000 targets that I trained the network with ? why the network cant predict the output as positive value like all the target ? so you are saying if the output is -0.00023, I can just assume it is 0.00023?
how can I define a nonnegative output function? Thank you
Greg Heath
Greg Heath on 29 Jul 2018
Edited: Greg Heath on 29 Jul 2018
Have ever heard of a sigmoid ?
G

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!