MATLAB Answers

NARX with multiple time series: Data dividision problem

13 ビュー (過去 30 日間)
Torsten K
Torsten K 2020 年 10 月 16 日
回答済み: Torsten K 2020 年 10 月 21 日
Hello everyone,
I want to train a NARX-model for multi-step prediction of time series. The task has the following boundary conditions:
1) 100 time series of different lengths in minute resolution
2) 2 inputs, 1 target
3) All time series have the shape of an exponential decay
4) All time series were first mixed (randperm) and then distributed to the sets for training (1:70), validation (71:85) and testing (86:100).
5) The time series of the sets are transformed to cell-arrays via 'catsamples' in order to train the network with multiple time series at once.
I am not sure how to divide the data properly. I would like to train the net with all the complete time-series of the training set and the validation set by using early stopping in order to avoid overfitting. The test set is used for testing the trained net with unseen data. But when I use the built-in functions for data division, the time series are torn apart:
net.divideFcn = 'divideblock';
net.divideMode = 'sampletime';
net.divideParam.trainRatio = 0.7; % First 70% of timesteps are used for training
net.divideParam.valRatio = 0.15; % Next 15% of timesteps are used for validation
net.divideParam.testRatio = 0.15; % Last 15% of timesteps are put aside for testing
This means that the first 70% of the timesteps are put into training set, the next 15% of the timesteps are put into validation set and the last 15% of the timesteps are put into test set.
So my question is:
How can I divide the data into three sets with complete time series which are not torn apart? I illustrated my question with the following 2 pictures:
Best regards

  1 件のコメント

Torsten K
Torsten K 2020 年 10 月 19 日
I would also be very happy to receive feedback from matlab staff. Please, dear experts, give me a hint how I can solve the problem or what I'm doing wrong!
Best regards



Torsten K
Torsten K 2020 年 10 月 21 日
OK, I found the solution. Here is a small example, based on this example:
load magmulseq;
y_mul = catsamples(y1,y2,y3,y1,y2,y3,'pad');
u_mul = catsamples(u1,u2,u3,u1,u2,u3,'pad');
d1 = [1:2];
d2 = [1:2];
narx_net = narxnet(d1,d2,10);
narx_net.divideMode = 'sample';
narx_net.divideFcn = 'divideind';
narx_net.divideParam.trainInd = 1:2;
narx_net.divideParam.valInd = 3:4;
narx_net.divideParam.testInd = 5:6;
[p,Pi,Ai,t] = preparets(narx_net,u_mul,{},y_mul);
[net tr] = train(narx_net,p,t,Pi);
If you check the training record tr, you can see the following for all 1484 time-steps:
>> tr.trainMask{1,1}
ans =
1 1 NaN NaN NaN NaN
>> tr.valMask{1,1}
ans =
NaN NaN 1 1 NaN NaN
>> tr.testMask{1,1}
ans =
NaN NaN NaN NaN 1 1
This is exactly what I wanted.
Best regards

  0 件のコメント


その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by