Interruption in the plotted data
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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')
Walter Roberson
2015 年 12 月 5 日
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
Walter Roberson
2015 年 12 月 5 日
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 );
Greg Heath
2015 年 12 月 6 日
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
Walter Roberson
2015 年 12 月 6 日
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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
