필터 지우기
필터 지우기

How to divide the data using "divideblock" for training and testing , excluding validation dataset in NAR network for time series prediction.

조회 수: 3 (최근 30일)
I am using NAR network for time series prediction. I have to divide my datset of 133 time points into training and tetsing dataset uisng "divideblock". I want first 106 points for training and the rest for testing. I am getting the error "Attempted to access valInd(0); index must be a positive integer or logical.
Error in divideblock>divide_indices testInd = (1:numTest)+valInd(end);
Error in divideblock [out1,out2,out3] = divide_indices(in1,params);".
Here is my code:
targetSeries = tonndata(untitled,false,false);
feedbackDelays = 1:1; hiddenLayerSize = 10; net = narnet(feedbackDelays,hiddenLayerSize);
net.inputs{1}.processFcns = {'removeconstantrows','mapminmax'}; [inputs,inputStates,layerStates,targets] = preparets(net,{},{},targetSeries);
net.divideFcn = 'divideblock'; [trainInd,valInd,testInd] = divideblock(133,0.8,0,0.2)
net.divideMode = 'time'; % Divide up every value net.divideParam.trainRatio = 80/100; net.divideParam.valRatio = 0/100; net.divideParam.testRatio = 20/100;
net.trainFcn = 'trainlm'; % Levenberg-Marquardt
net.performFcn = 'mse'; % Mean squared error
net.plotFcns = {'plotperform','plottrainstate','plotresponse','ploterrcorr', 'plotinerrcorr'};
[net,tr] = train(net,inputs,targets,inputStates,layerStates);
outputs = net(inputs,inputStates,layerStates);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs)
trainTargets = gmultiply(targets,tr.trainMask);
valTargets = gmultiply(targets,tr.valMask);
testTargets = gmultiply(targets,tr.testMask);
trainPerformance = perform(net,trainTargets,outputs)
valPerformance = perform(net,valTargets,outputs)
testPerformance = perform(net,testTargets,outputs)
view(net)
netc = closeloop(net); [xc,xic,aic,tc] = preparets(netc,{},{},targetSeries); yc = netc(xc,xic,aic); perfc = perform(net,tc,yc)
nets = removedelay(net);
[xs,xis,ais,ts] = preparets(nets,{},{},targetSeries);
ys = nets(xs,xis,ais);
closedLoopPerformance = perform(net,tc,yc)

답변 (1개)

Kazi Tamaddun
Kazi Tamaddun 2018년 5월 17일
편집: Kazi Tamaddun 2018년 5월 17일
Your valRatio cannot be zero. You can make your testRatio to be zero if you want.

카테고리

Help CenterFile Exchange에서 Signal Modeling에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by