Please i need help on how to determine R squared for training, validation, testing and ALL in neural network with a simple code.

조회 수: 37 (최근 30일)
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

댓글을 달려면 로그인하십시오.

채택된 답변

fred  ssemwogerere
fred ssemwogerere 2020년 2월 18일
"..........Each time I click on plotregression, I see thier R2......"
Hello, point of correction; regression plots of your modeled network show the correlation coefficient,"R" (a measure of the magnitude and direction of linear association between the defined variables), but not the coefficient of determination, "Rsquared / R2" (a measure of the magnitude of variability modeled by the network in your output,'y'). However, R=squareroot(R2). Added to that, a number of answers have been previously given on how to obtain this correlation coefficient you desire. Please refer to the links below:
Alternatively you could refer to the matlab documentation in the link below, with an example of obtaining the correlation coefficient from the general or "All" plot:

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by