Interruption in the plotted data
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hi all,
I use a neural network toolbox to predict the values of the last week in the used data year. When I plot the figure, the Interruption in the plotted data are appearing! Knowing that, the data are interpolated and there is no NaN in it.
SEE the attached figure
Please anyone can help I will appreciate it. Thank you
채택된 답변
Walter Roberson
2015년 12월 5일
편집: Walter Roberson
2015년 12월 5일
I loaded the figure and examined the data, and there certainly are NaN in it.
h = openfig('predicted.fig');
L = findobj(h, 'type', 'line');
L7y = get(L(7), 'YData');
find(~isnan(L7y(1:8594))
ans =
8594
In other words, the first 8593 Y values of Expected Outputs are NaN and position 8594 is the first non-NaN. The same holds true for L(8), Network Predictions. The data for L(9), Original Targets, on the other hand, is valid only up to point 8593, and is NaN from 8594 onwards.
With the last non-NAN point from the left being 8593 and the first non-NaN point from the right being 8594, you will have a gap between 8593 and 8594, exactly like you are seeing.
댓글 수: 15
Lilya
2015년 12월 5일
In the original data there are no NaN values, it's only appeared after plotting. Here is the part of code which contain the problem
inputSeriesVal = X(end-N+1:end);
targetSeriesVal = T(end-N+1:end);
%%3. Network Architecture
delay = 3;
neuronsHiddenLayer = 30;
% Create a Nonlinear Autoregressive Network with External Input
% net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
net = narxnet(1:delay,1:delay,neuronsHiddenLayer);
%%4. Training the network
[Xs,Xi,Ai,Ts] = preparets(net,inputSeries,{},targetSeries);
net = train(net,Xs,Ts,Xi,Ai);
view(net)
[Y,xf,af] = net(Xs,Xi,Ai);
% Performance for the series-parallel implementation, only
% one-step-ahead prediction
perf = perform(net,Ts,Y);
%%5. Multi-step ahead prediction
[netc,xi,ai] = closeloop(net,xf,af);
[yPred,xf,af] = netc(inputSeriesVal,xi,ai);
view(netc)
figure;
plot([cell2mat(targetSeries),nan(1,N);
nan(1,length(targetSeries)),cell2mat(yPred);
nan(1,length(targetSeries)),cell2mat(targetSeriesVal)]')
legend('Original Targets','Network Predictions','Expected Outputs')
Look at your plot call:
plot([cell2mat(targetSeries),nan(1,N);
nan(1,length(targetSeries)),cell2mat(yPred);
nan(1,length(targetSeries)),cell2mat(targetSeriesVal)]')
You use nan in the first line, nan in the second line, nan in the third line. You are adding the NaN. And NaN are not plotted.
In the first of those lines, you have length(targetSeries) valid data points and then N Nan. In the second line, you have length(targetSeries) Nan and then N data points. In order for there to be no gap, you would need overlap
XXXX000
0000XXX
To get a line with no gap you would need
XXXXX00
0000XXX
or
XXXX000
000XXXX
some position at which there is non-NaN data for both rows.
Lilya
2015년 12월 5일
I tried to solve it, but I can't :( How can I change the plotting commands to avoid this?
Thank you Mr. Roberson
You can get it to draw the line connections, but they will not be valid line connections unless you ask it to predict the value at length(targetSeries)
Suppose I gave you data for points 1, 2, 3, and 4, and asked you to predict points 5 and 6, and then I drew a line through points 1 through 4 (the known) and I drew a line through points 5 and 6 (what you predicted) and then I complained that there is no line between points 4 and points 5. But I never asked you to predict anything between 4 and 5, so there is no data for that line to work with. I would have to give you points 1, 2, 3, and 4 and ask you to predict points 4, 5, and 6 in order to validly draw a line from 1 through 4 and a line from 4 through 6. (Of course if your prediction of those known values is not the same as the actual values, there may be a visual gap anyhow...)
You will find it easier if you change the way you are plotting.
ntarg = length(targetSeries);
plot(1:ntarg, mat2cell(targetSeries), ...
ntarg : length(X), cell2mat(yPred_2), ...
ntarg : length(X), cell2mat(targetSeriesVal_2) );
Here yPred_2 is like your current yPred except that it would have to be formed starting from x(ntarg) instead of from x(ntarg+1) like it is at present (that is, you need to ask to predict an existing value.) Likewise targetSeriesVal_2 would be starting from T(ntarg) instead of from T(ntarg+1) -- one value overlapping.
Lilya
2015년 12월 6일
Thank you very much Roberson. But It is still a problem in dim. The first line in the plot command is working, but the others it did not.
Walter Roberson
2015년 12월 6일
Did you create yPred_2 as starting from a pointer earlier than you used to start it?
What is length(X), length(targetSeries), size(yPred_2), size(targetSeriesVal_2) ?
Lilya
2015년 12월 6일
yes I am. I actully did
yPred_2=cell2mat(yPred)-1;
targetSeriesVal_2=cell2mat(targetSeriesVal)+1;
figure;
ntarg = length(targetSeries);
plot(1:ntarg, cell2mat(targetSeries), ...
ntarg : length(X), yPred_2, ...
ntarg : length(X), targetSeriesVal_2 );
Going back to basics:
I question your choice of delays and number of hidden nodes.
Why 1:3, 1:3, 30 ???
Did you try your NARXNET code on
[ X T ] = simpleseries_dataset;
Search
greg narxnet
Like this: notice the change to start the prediction data from exactly 1 point earlier than you had before
inputSeriesVal = X(end-N+0:end); %CHANGED
targetSeriesVal = T(end-N+0:end); %CHANGED
%%3. Network Architecture
delay = 3;
neuronsHiddenLayer = 30;
% Create a Nonlinear Autoregressive Network with External Input
% net = narxnet(inputDelays,feedbackDelays,hiddenLayerSize);
net = narxnet(1:delay,1:delay,neuronsHiddenLayer);
%%4. Training the network
[Xs,Xi,Ai,Ts] = preparets(net,inputSeries,{},targetSeries);
net = train(net,Xs,Ts,Xi,Ai);
view(net)
[Y,xf,af] = net(Xs,Xi,Ai);
% Performance for the series-parallel implementation, only
% one-step-ahead prediction
perf = perform(net,Ts,Y);
%%5. Multi-step ahead prediction
[netc,xi,ai] = closeloop(net,xf,af);
[yPred,xf,af] = netc(inputSeriesVal,xi,ai);
view(netc)
figure;
ntarg = length(targetSeries);
plot(1:ntarg, mat2cell(targetSeries), ...
ntarg : length(X), cell2mat(yPred), ...
ntarg : length(X), cell2mat(targetSeriesVal) );
legend('Original Targets','Network Predictions','Expected Outputs')
Lilya
2015년 12월 6일
THANK YOU AS A HUGE UNIVERSE :'(
Lilya
2015년 12월 7일
Dr. Heath, I see the NARXNET examples. The best result I had gotten when the number of HN =30. Is it right?
Greg Heath
2015년 12월 7일
편집: Greg Heath
2015년 12월 7일
It does not predict as desired. It would help if you posted all code and results using the simpleseries_dataset.
I recommend starting a new thread for this because it is a separate problem.
Greg
Lilya
2015년 12월 8일
Dr. Heath, according to simpleseries_dataset code there is a difference between it and NAREXNET. Is it in the coding or in the implementation of the function itself?
Walter Roberson
2015년 12월 8일
Please start a new question.
Lilya
2015년 12월 8일
I apologize
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
