MAPE for out-of-sample in neural network
3 views (last 30 days)
Show older comments
Janthorn Sinthupundaja
on 27 Mar 2015
Commented: Angelina Tan
on 17 Apr 2022
How to compute MAPE for out-of-sample in neural network?
Input value is 12x1505 double. Target value is 1x1505 double.
Here is my code:
x = Input';
t = Target';
trainFcn = 'trainlm';
hiddenLayerSize = 3;
net = feedforwardnet(hiddenLayerSize,trainFcn);
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.output.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'divideind';
net.divideParam.trainInd = 1:903;
net.divideParam.valInd = 904:1204;
net.divideParam.testInd = 1205:1505.
net.performFcn = 'mse';
[net,tr] = train(net,x,t);
y = net(x);
e = gsubtract(t,y);
performance = mse(net,t,y)
trainTargets = t .* tr.trainMask{1};
valTargets = t .* tr.valMask{1};
testTargets = t .* tr.testMask{1};
trainPerformance = perform(net,trainTargets,y)
valPerformance = perform(net,valTargets,y)
testPerformance = perform(net,testTargets,y)
view(net)
Thank you very much
Janthorn
0 Comments
Accepted Answer
Greg Heath
on 30 Mar 2015
Not sure why you would use a measure that has the possibility of being infinite. However
mape = mean(abs(e./t))
Hope this helps
Thank you for formally accepting my answer
Greg
2 Comments
Andres Romero
on 12 Sep 2016
There is a way to separete Inf and -Inf values? from a vector A = [1;Inf;-Inf;2;6;3]
More Answers (0)
See Also
Categories
Find more on Define Shallow Neural Network Architectures 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!