When splitting data into training, validation, test data sets to be fed to machine learning model, the data is ideally expected to be stationary. However, in the real world, some data is non-stationary. For example, financial time-series data are non-stationary.

So, for this kind of non-stationary data, how do you split data into training, validation, test data sets?

  • $\begingroup$ I think you meant "ideally stationary..." is it right? $\endgroup$
    – German C M
    Dec 18, 2020 at 10:10
  • $\begingroup$ yes. Ideally stationary will be right. $\endgroup$
    – user781486
    Dec 18, 2020 at 10:41

1 Answer 1


In general, for time series data, you can split it in such a way that the temporal order is as is in all your splits (training, validation and testing sets).

Once you make your series stationary (via differentiation for instance), you can make use of the TimeSeriesSplit cross-validator by scikit-learn, with wich you get the time-ordered indices of each train-validation split, so that you can use them later on with the validation strategy you might want to use, something like:

enter image description here

As a possible validation strategy, you could use the walk-forward validation (nice info here)


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.