Please i need help on how to determine R squared for training, validation, testing and ALL in neural network with a simple code.
Mostrar comentarios más antiguos
Please how can I determine the correlation coefficient of training, validation, testing and ALL in neural net with a simple code.Each time I click on plotregression, I see thier R2 but would like to include it in my code and view only the values.
load ('t.mat');
load ('x.mat');
x = input';
t = Target';
% 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.
% Levenberg-Marquardt backpropagation.
trainFcn = 'trainlm';
%% Create a Fitting Network
hiddenLayerSize = 10;
net = fitnet(hiddenLayerSize,trainFcn);
%% Setup Division of Data for Training, Validation, Testing
[trainInd,valInd,testInd] = divideint(x,0.70,0.15,0.15);
%% Train the Network
net.performParam.regularization = 0.0001;
[net,tr] = train(net,x,t);
%% Number of validation checks
net.trainParam.min_grad
nntraintool
%%
% Test the Network
y = net(x);
e = gsubtract(t,y);
performance = perform(net,t,y);
perf = mse(net, t, y, 'regularization', 0.01);
perf = crossentropy(net,t,y,{1},'regularization',0.01);
%% Calculate network perfomance on test
tInd = tr.testInd
tsty = net(x(:,tInd))
tstPerform = perform(net,t(:,tInd),tsty)
%% Check train records
tr
%% View the Network diagram
view(net)
%% Plots
% Uncomment these lines to enable various plots.
trOut = y(tr.trainInd)
vOut = y(tr.valInd)
tsOut = y(tr.testInd)
trTarg = t(tr.trainInd)
vTarg = t(tr.valInd)
tsTarg = t(tr.testInd)
%% performance figure,
figure
plotperform(tr);
%% trainstate figure,
figure
plottrainstate(tr);
%% Errorhistogram figure,
figure
ploterrhist(e);
%% Regression figure,
figure
plotregression(trTarg, trOut, 'Train', vTarg, vOut, 'Validation', tsTarg, tsOut, 'Test', t,y, 'All');
3 comentarios
BN
el 18 de Feb. de 2020
Dear Ikechukwu
net.performFcn = 'mse'; % Mean Squared Error
%% Calculate network perfomance on test
tInd = tr.testInd
tsty = net(x(:,tInd))
tstPerform = perform(net,t(:,tInd),tsty)
RMSE_test=sqrt(tstPerform);
fprintf('RMSE on the test set is %f\n',RMSE_test)
% Do same for tarin and validation
Level 2
el 19 de Feb. de 2020
Seray Mirasci
el 13 de Nov. de 2022
Thank you, it helped me too :)
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!