How to obtain additional test result in neural network fitting app by using code?
Hi,
I am using the neural network fitting app in MATLAB 2024a version.
I used the code to develop the neural network by adding a hidden layer.
When I use this code, it shows the results for training, but I can’t get the results for the additional test set as shown in the neural network fitting app.
How can I get it? (e.g. the name of additional test input is "inputtest" and that of additional test output(target) is "outputtes")
I wrote my code below.
% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 09-Jun-2024 21:04:21
%
% This script assumes these variables are defined:
%
% bodyfatInputs – input data.
% bodyfatTargets – target data.
x = bodyfatInputs;
t = bodyfatTargets;
% 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 = ‘trainlm’; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayer1Size = 10;
hiddenLayer2Size = 10;
net = fitnet([hiddenLayer1Size, hiddenLayer2Size],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)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t)Hi,
I am using the neural network fitting app in MATLAB 2024a version.
I used the code to develop the neural network by adding a hidden layer.
When I use this code, it shows the results for training, but I can’t get the results for the additional test set as shown in the neural network fitting app.
How can I get it? (e.g. the name of additional test input is "inputtest" and that of additional test output(target) is "outputtes")
I wrote my code below.
% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 09-Jun-2024 21:04:21
%
% This script assumes these variables are defined:
%
% bodyfatInputs – input data.
% bodyfatTargets – target data.
x = bodyfatInputs;
t = bodyfatTargets;
% 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 = ‘trainlm’; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayer1Size = 10;
hiddenLayer2Size = 10;
net = fitnet([hiddenLayer1Size, hiddenLayer2Size],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)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t) Hi,
I am using the neural network fitting app in MATLAB 2024a version.
I used the code to develop the neural network by adding a hidden layer.
When I use this code, it shows the results for training, but I can’t get the results for the additional test set as shown in the neural network fitting app.
How can I get it? (e.g. the name of additional test input is "inputtest" and that of additional test output(target) is "outputtes")
I wrote my code below.
% Solve an Input-Output Fitting problem with a Neural Network
% Script generated by Neural Fitting app
% Created 09-Jun-2024 21:04:21
%
% This script assumes these variables are defined:
%
% bodyfatInputs – input data.
% bodyfatTargets – target data.
x = bodyfatInputs;
t = bodyfatTargets;
% 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 = ‘trainlm’; % Levenberg-Marquardt backpropagation.
% Create a Fitting Network
hiddenLayer1Size = 10;
hiddenLayer2Size = 10;
net = fitnet([hiddenLayer1Size, hiddenLayer2Size],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)
% View the Network
view(net)
% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, ploterrhist(e)
%figure, plotregression(t,y)
%figure, plotfit(net,x,t) neural network, neural networks fitting MATLAB Answers — New Questions