# How to Use the TimeseriesGenerator for Time Series Forecasting in Keras

Last Updated on

Time series data must be transformed into a structure of samples with input and output components before it can be used to fit a supervised learning model.

This can be challenging if you have to perform this transformation manually. The Keras deep learning library provides the TimeseriesGenerator to automatically transform both univariate and multivariate time series data into samples, ready to train deep learning models.

In this tutorial, you will discover how to use the Keras TimeseriesGenerator for preparing time series data for modeling with deep learning methods.

After completing this tutorial, you will know:

• How to define the TimeseriesGenerator generator and use it to fit deep learning models.
• How to prepare a generator for univariate time series and fit MLP and LSTM models.
• How to prepare a generator for multivariate time series and fit an LSTM model.

Discover how to build models for multivariate and multi-step time series forecasting with LSTMs and more in my new book, with 25 step-by-step tutorials and full source code.

Let’s get started. How to Use the TimeseriesGenerator for Time Series Forecasting in Keras
Photo by Chris Fithall, some rights reserved.

## Tutorial Overview

This tutorial is divided into six parts; they are:

1. Problem with Time Series for Supervised Learning
2. How to Use the TimeseriesGenerator
3. Univariate Time Series Example
4. Multivariate Time Series Example
5. Multivariate Inputs and Dependent Series Example
6. Multi-step Forecasts Example

Note: This tutorial assumes that you are using Keras v2.2.4 or higher.

## Problem with Time Series for Supervised Learning

Time series data requires preparation before it can be used to train a supervised learning model, such as a deep learning model.

For example, a univariate time series is represented as a vector of observations:

A supervised learning algorithm requires that data is provided as a collection of samples, where each sample has an input component (X) and an output component (y).

The model will learn how to map inputs to outputs from the provided examples.

A time series must be transformed into samples with input and output components. The transform both informs what the model will learn and how you intend to use the model in the future when making predictions, e.g. what is required to make a prediction (X) and what prediction is made (y).

For a univariate time series interested in one-step predictions, the observations at prior time steps, so-called lag observations, are used as input and the output is the observation at the current time step.

For example, the above 10-step univariate series can be expressed as a supervised learning problem with three time steps for input and one step as output, as follows:

You can write code to perform this transform yourself; for example, see the post:

Alternately, when you are interested in training neural network models with Keras, you can use the TimeseriesGenerator class.

### Need help with Deep Learning for Time Series?

Take my free 7-day email crash course now (with sample code).

Click to sign-up and also get a free PDF Ebook version of the course.

## How to use the TimeseriesGenerator

Keras provides the TimeseriesGenerator that can be used to automatically transform a univariate or multivariate time series dataset into a supervised learning problem.

There are two parts to using the TimeseriesGenerator: defining it and using it to train models.

### Defining a TimeseriesGenerator

You can create an instance of the class and specify the input and output aspects of your time series problem and it will provide an instance of a Sequence class that can then be used to iterate across the inputs and outputs of the series.

In most time series prediction problems, the input and output series will be the same series.

For example:

Technically, the class is not a generator in the sense that it is not a Python Generator and you cannot use the next() function on it.

In addition to specifying the input and output aspects of your time series problem, there are some additional parameters that you should configure; for example:

• length: The number of lag observations to use in the input portion of each sample (e.g. 3).
• batch_size: The number of samples to return on each iteration (e.g. 32).

You must define a length argument based on your designed framing of the problem. That is the desired number of lag observations to use as input.

You must also define the batch size as the batch size of your model during training. If the number of samples in your dataset is less than your batch size, you can set the batch size in the generator and in your model to the total number of samples in your generator found via calculating its length; for example:

There are also other arguments such as defining start and end offsets into your data, the sampling rate, stride, and more. You are less likely to use these features, but you can see the full API for more details.

The samples are not shuffled by default. This is useful for some recurrent neural networks like LSTMs that maintain state across samples within a batch.

It can benefit other neural networks, such as CNNs and MLPs, to shuffle the samples when training. Shuffling can be enabled by setting the ‘shuffle‘ argument to True. This will have the effect of shuffling samples returned for each batch.

At the time of writing, the TimeseriesGenerator is limited to one-step outputs. Multi-step time series forecasting is not supported.

### Training a Model with a TimeseriesGenerator

Once a TimeseriesGenerator instance has been defined, it can be used to train a neural network model.

A model can be trained using the TimeseriesGenerator as a data generator. This can be achieved by fitting the defined model using the fit_generator() function.

This function takes the generator as an argument. It also takes a steps_per_epoch argument that defines the number of samples to use in each epoch. This can be set to the length of the TimeseriesGenerator instance to use all samples in the generator.

For example:

Similarly, the generator can be used to evaluate a fit model by calling the evaluate_generator() function, and using a fit model to make predictions on new data with the predict_generator() function.

A model fit with the data generator does not have to use the generator versions of the evaluate and predict functions. They can be used only if you wish to have the data generator prepare your data for the model.

## Univariate Time Series Example

We can make the TimeseriesGenerator concrete with a worked example with a small contrived univariate time series dataset.

First, let’s define our dataset.

We will choose to frame the problem where the last two lag observations will be used to predict the next value in the sequence. For example:

For now, we will use a batch size of 1, so that we can explore the data in the generator.

Next, we can see how many samples will be prepared by the data generator for this time series.

Finally, we can print the input and output components of each sample, to confirm that the data was prepared as we expected.

The complete example is listed below.

Running the example first prints the total number of samples in the generator, which is eight.

We can then see that each input array has the shape [1, 2] and each output has the shape [1,].

The observations are prepared as we expected, with two lag observations that will be used as input and the subsequent value in the sequence as the output.

Now we can fit a model on this data and learn to map the input sequence to the output sequence.

The generator will be defined so that all samples will be used in each batch, given the small number of samples.

We can define a simple model with one hidden layer with 50 nodes and an output layer that will make the prediction.

We can then fit the model with the generator using the fit_generator() function. We only have one batch worth of data in the generator so we’ll set the steps_per_epoch to 1. The model will be fit for 200 epochs.

Once fit, we will make an out of sample prediction.

Given the inputs [9, 10], we will make a prediction and expect the model to predict , or close to it. The model is not tuned; this is just an example of how to use the generator.

The complete example is listed below.

Running the example prepares the generator, fits the model, and makes the out of sample prediction, correctly predicting a value close to 11.

We can also use the generator to fit a recurrent neural network, such as a Long Short-Term Memory network, or LSTM.

The LSTM expects data input to have the shape [samples, timesteps, features], whereas the generator described so far is providing lag observations as features or the shape [samples, features].

We can reshape the univariate time series prior to preparing the generator from [10, ] to [10, 1] for 10 time steps and 1 feature; for example:

The TimeseriesGenerator will then split the series into samples with the shape [batch, n_input, 1] or [8, 2, 1] for all eight samples in the generator and the two lag observations used as time steps.

The complete example is listed below.

Again, running the example prepares the data, fits the model, and predicts the next out of sample value in the sequence.

## Multivariate Time Series Example

The TimeseriesGenerator also supports multivariate time series problems.

These are problems where you have multiple parallel series, with observations at the same time step in each series.

We can demonstrate this with an example.

First, we can contrive a dataset of two parallel series.

It is a standard structure to have multivariate time series formatted such that each time series is a separate column and rows are the observations at each time step.

The series we have defined are vectors, but we can convert them into columns. We can reshape each series into an array with the shape [10, 1] for the 10 time steps and 1 feature.

We can now horizontally stack the columns into a dataset by calling the hstack() NumPy function.

We can now provide this dataset to the TimeseriesGenerator directly. We will use the prior two observations of each series as input and the next observation of each series as output.

Each sample will then be a three-dimensional array of [1, 2, 2] for the 1 sample, 2 time steps, and 2 features or parallel series. The output will be a two-dimensional series of [1, 2] for the 1 sample and 2 features. The first sample will be:

The complete example is listed below.

Running the example will first print the prepared dataset, followed by the total number of samples in the dataset.

Next, the input and output portion of each sample is printed, confirming our intended structure.

The three-dimensional structure of the samples means that the generator cannot be used directly for simple models like MLPs.

This could be achieved by first flattening the time series dataset to a one-dimensional vector prior to providing it to the TimeseriesGenerator and set length to the number of steps to use as input multiplied by the number of columns in the series (n_steps * n_features).

A limitation of this approach is that the generator will only allow you to predict one variable. You almost certainly may be better off writing your own function to prepare multivariate time series for an MLP than using the TimeseriesGenerator.

The three-dimensional structure of the samples can be used directly by CNN and LSTM models. A complete example for multivariate time series forecasting with the TimeseriesGenerator is listed below.

Running the example prepares the data, fits the model, and makes a prediction for the next value in each of the input time series, which we expect to be [110, 115].

## Multivariate Inputs and Dependent Series Example

There are multivariate time series problems where there are one or more input series and a separate output series to be forecasted that is dependent upon the input series.

To make this concrete, we can contrive one example with two input time series and an output series that is the sum of the input series.

Where values in the output sequence are the sum of values at the same time step in the input time series.

This is different from prior examples where, given inputs, we wish to predict a value in the target time series for the next time step, not the same time step as the input.

For example, we want samples like:

We don’t want samples like the following:

Nevertheless, the TimeseriesGenerator class assumes that we are predicting the next time step and will provide data as in the second case above.

For example:

Running the example prints the input and output portions of the samples with the output values for the next time step rather than the current time step as we may desire for this type of problem.

We can therefore modify the target series (out_seq) and insert an additional value at the beginning in order to push all observations down by one time step.

This artificial shift will allow the preferred framing of the problem.

The complete example with this shift is provided below.

Running the example shows the preferred framing of the problem.

This approach will work regardless of the length of the input sample.

## Multi-step Forecasts Example

A benefit of neural network models over many other types of classical and machine learning models is that they can make multi-step forecasts.

That is, that the model can learn to map an input pattern of one or more features to an output pattern of more than one feature. This can be used in time series forecasting to directly forecast multiple future time steps.

This can be achieved either by directly outputting a vector from the model, by specifying the desired number of outputs as the number of nodes in the output layer, or it can be achieved by specialized sequence prediction models such as an encoder-decoder model.

A limitation of the TimeseriesGenerator is that it does not directly support multi-step outputs. Specifically, it will not create the multiple steps that may be required in the target sequence.

Nevertheless, if you prepare your target sequence to have multiple steps, it will honor and use them as the output portion of each sample. This means the onus is on you to prepare the expected output for each time step.

We can demonstrate this with a simple univariate time series with two time steps in the output sequence.

You can see that you must have the same number of rows in the target sequence as you do in the input sequence. In this case, we must know values beyond the values in the input sequence, or trim the input sequence to the length of the target sequence.

The complete example is listed below.

Running the example prints the input and output portions of the samples showing the two lag observations as input and the two steps as output in the multi-step forecasting problem.

This section provides more resources on the topic if you are looking to go deeper.

## Summary

In this tutorial, you discovered how to use the Keras TimeseriesGenerator for preparing time series data for modeling with deep learning methods.

Specifically, you learned:

• How to define the TimeseriesGenerator generator and use it to fit deep learning models.
• How to prepare a generator for univariate time series and fit MLP and LSTM models.
• How to prepare a generator for multivariate time series and fit an LSTM model.

Do you have any questions?

## Develop Deep Learning models for Time Series Today! #### Develop Your Own Forecasting models in Minutes

...with just a few lines of python code

Discover how in my new Ebook:
Deep Learning for Time Series Forecasting

It provides self-study tutorials on topics like:
CNNs, LSTMs, Multivariate Forecasting, Multi-Step Forecasting and much more...

### 56 Responses to How to Use the TimeseriesGenerator for Time Series Forecasting in Keras

1. Jesper November 8, 2018 at 5:37 am #

Hi Jason
Great tutorials.
When I run your code. The univariate one step problem with lstm.
there is an error when running model.fit

Traceback (most recent call last):
File “”, line 2, in
File “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\keras\legacy\interfaces.py”, line 91, in wrapper
return func(*args, **kwargs)
File “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\keras\engine\training.py”, line 1415, in fit_generator
initial_epoch=initial_epoch)
File “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\keras\engine\training_generator.py”, line 177, in fit_generator
generator_output = next(output_generator)
File “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\keras\utils\data_utils.py”, line 793, in get
six.reraise(value.__class__, value, value.__traceback__)
File “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\six.py”, line 693, in reraise
raise value
File “C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\keras\utils\data_utils.py”, line 658, in _data_generator_task
generator_output = next(self._generator)
TypeError: ‘TimeseriesGenerator’ object is not an iterator

Something you know how to overcome?

• Jason Brownlee November 8, 2018 at 6:13 am #

Are you able to confirm that you Keras library is up to date?

E.g. v2.2.4 or higher?

• Jesper November 8, 2018 at 8:10 am #

Hi Jason

No, I was running v2.2.2 but have updated now to 2.2.4 and it works 🙂

Thank you

• Jason Brownlee November 8, 2018 at 2:11 pm #

Glad to hear it. I have added a note to the tutorial.

2. Jenna Ma November 8, 2018 at 7:22 pm #

Hi Jason,
Thanks for the tutorials, it helps me a lot.
But I still have a huge problem when I deal with my dataset. I think it’s a multi-site multivariate time series forecasting dataset (the trajectory data of multiple vehicles over a period of time). I don’t know how to pre-process it before using the TimeseriesGenerator.
Could you give me some advice?
Thanks a lot.

• Jason Brownlee November 9, 2018 at 5:20 am #

Before pre-processing, perhaps start with a strong framing of the problem — it will guide you as to how to prepare the data.

• Jenna Ma November 9, 2018 at 2:14 pm #

Thanks for your advice. But what is a frame? Like a model? I don’t quite understand. Could you give a simple example or a link?

• Jenna Ma November 9, 2018 at 6:23 pm #

I have read another article titled ‘A Standard Multivariate, Multi-Step, and Multi-Site Time Series Forecasting Problem’ on your blog. I have some kind of understanding the framing problem.
My project is quite like the ‘Air Quality Prediction’ project. Do you think it’s possible to use LSTM for the global forecasting problem?

• Jason Brownlee November 10, 2018 at 5:59 am #

Perhaps try it and see.

3. Bert November 9, 2018 at 7:30 am #

Great tutorial Jason. I was wondering how you could include other independent variables to forecast the output. In my case I want to forecast the air pollution for a set of measurement stations. Besides the historical pollution I also have other variables like termperature and humidity. Do you know how to deal with that? Thanks!

• Jason Brownlee November 9, 2018 at 2:01 pm #

I show how to use it for multivariate data with a dependent series, does that help?

4. Evan November 9, 2018 at 8:45 pm #

Hey, thanks for the great tutorial.

I’m getting an error in the multivariate case. When I insert the 0 the input and output series’ aren’t the same length anymore:

ValueError: Data and targets have to be of same length. Data length is 10 while target length is 11

• Jason Brownlee November 10, 2018 at 6:05 am #

Hmmm, perhaps post to stackoverflow or Keras help:
https://machinelearningmastery.com/get-help-with-keras/

• Masahiro March 1, 2019 at 6:20 pm #

Hi, Jason and Evan.

The numpy.insert() adds new value(s) to existing array.
So, in case of your example, “out_seq = insert(out_seq, 0, 0)” makes out_seq 1-size bigger.
I think that this occurs the Evan’s error.

You need to do the following before create a generator.

from numpy import delete
out_seq = delete(out_seq, -1)

• Jason Brownlee March 2, 2019 at 9:29 am #

Thanks for sharing.

5. Lu November 15, 2018 at 2:07 am #

thanks for your great tutorial, I copy your code and run it in my pycharm, and found that the result is different from yours, the sample number is always one less than yours, when your is 8 my is 7.

# univariate one step problem
from numpy import array
from keras.preprocessing.sequence import TimeseriesGenerator
# define dataset
series = array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
# define generator
n_input = 2
generator = TimeseriesGenerator(series, series, length=n_input, batch_size=1)
# number of samples
print(‘Samples: %d’ % len(generator))
# print each sample
for i in range(len(generator)):
x, y = generator[i]
print(‘%s => %s’ % (x, y))

#Resluts:
Samples: 7
[[1. 2.]] => [3.]
[[2. 3.]] => [4.]
[[3. 4.]] => [5.]
[[4. 5.]] => [6.]
[[5. 6.]] => [7.]
[[6. 7.]] => [8.]
[[7. 8.]] => [9.]

• Jason Brownlee November 15, 2018 at 5:36 am #

Are you able to confirm that your libraries are up to date?

• Lu November 15, 2018 at 12:13 pm #

Yes, I checked my keras version and update it to the latest one, now the result is same to you. Thank youuuuuu!!

• Jason Brownlee November 16, 2018 at 6:10 am #

6. zhen hong December 19, 2018 at 7:08 pm #

Hi jason,
I have a question now.
I want to generate sequences which give a certain seed and end, like the sentence begin with “hello” and end with “bye”
Do u have any idea about it?
Thanks a lot.

• Jason Brownlee December 20, 2018 at 6:24 am #

Yes, if your training data has this then the model will learn it.

7. cnkostas December 22, 2018 at 4:03 am #

Hi Mr jason
As Evan mentioned above i have the same error for the same example

ValueError: Data and targets have to be of same length. Data length is 10 while target length is 11

• Jason Brownlee December 22, 2018 at 6:07 am #

Confirm that your version of Keras is 2.2.4 or higher and tensorflow is 1.12. or higher.

• Alexander Severinsen January 4, 2019 at 10:16 pm #

I get the same error message in the Multivariate Inputs and Dependent Series Example

when target shifts

# shift the target sample by one step
out_seq = insert(out_seq, 0, 0)

target is length 11 and data 10

# confirm Keras version
import keras;
print(keras.__version__)
2.2.4

• Jason Brownlee January 5, 2019 at 6:57 am #

What version of tensorflow are you using?

• John Richardson May 15, 2019 at 11:04 am #

If you are shifting the target, you should also shift the data:

dataset = np.append(dataset, [ * np.size(dataset, axis=1)], axis=0)
out_seq = np.insert(out_seq, 0, 0)

8. TAMER A. FARRAG January 24, 2019 at 6:10 am #

How “TimeseriesGenerator” differ from the function “series_to_supervised” that you have used it in many other tutorials?

• Jason Brownlee January 24, 2019 at 6:49 am #

In many ways. What differences are you interested in exactly?

9. Sergio February 15, 2019 at 12:47 am #

Suppose a multi-step ahead (2 steps) for univariate series (using 3 lags) as:

series = array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])

target = array([[1,2],[2,3],[3,4],[4,5],[5,6],[6,7],[7,8],[8,9],[9,10],[10,11]])

# define generator
n_input = 3
generator = TimeseriesGenerator(series, target, length=n_input, batch_size=1)

n_features=1
n_output=2

# define model

model_lstm2 = Sequential()
input_shape=(n_input, n_features)))
model_lstm2.compile(optimizer=’sgd’, loss=’mse’)
# fit model
history_lstm2=model_lstm2.fit_generator(generator, steps_per_epoch=1, epochs=50, verbose=1)
plt.plot(history_lstm2.history[‘loss’])

I get an error:

“Error when checking input: expected lstm_26_input to have 3 dimensions, but got array with shape (1, 3)”

I suppose that there is something wrong with “generator”, as, I suppose, lstm ipunt_shape is correct, but how to change for this case?

Thanks.

10. Fab April 20, 2019 at 6:20 am #

Just wanted to say thank you, was going crazy building x and y (multivariate x), until I ended up here… This article helped me keeping my (somewhat) sanity!

• Jason Brownlee April 20, 2019 at 7:44 am #

Thanks, hang in there!

11. Sammy July 28, 2019 at 6:26 am #

Hi Jason, excellent tutorial! It really answered alot of questions that have been bothering me about time series forecast the last week.

Can you please give a very simple real life use case of a Multivariate Inputs and Dependent Series problem? I am just trying to get a better picture in my mind of when I would need to apply this.

12. Sammy July 29, 2019 at 11:49 am #

Hi Jason, Thanks again for posting this tutorial.

I am working on a project to perform future forecasting of stock data. I have 13 features and 2.5 years of data to train my LSTM. I tried implementing a generator to do some future forecasting (5 days into the future) but i receive the error:

ValueError: Error when checking input: expected lstm_1_input to have shape (529, 13) but got array with shape (5, 13)

would this be due to my input and output shapes? Right now I have them set to the same array:

generator = TimeseriesGenerator(stock_dataset, stock_dataset, length = n_lag, batch_size = 8)

In this case would using my array “stock_dataset” as the input (data) and output (target) make sense because the data output I am looking for is the same shape as the input data. Please if you can provide some guidance on this and let me know if this is the cause of my ValueError. Thank you so much in advance!

• Jason Brownlee July 29, 2019 at 2:22 pm #

It suggests a mismatch between the shape of one sample provided by the generator and the expectation of the model.

You can change the generator to match the model or change the model to match the data.

More on the 3D shape expected by an LSTM here:
https://machinelearningmastery.com/faq/single-faq/what-is-the-difference-between-samples-timesteps-and-features-for-lstm-input

• Sammy July 30, 2019 at 2:27 am #

Hi Jason, thanks again for the links. I am a little confused because in the links you provide you said the input layer for an LSTM expects a 3D array as input but your example above you are only passing a 2D array from the generator:

Also in the keras documentation for TimeseriesGenerator it also mentions the input shape should be a 2D array.

• Jason Brownlee July 30, 2019 at 6:21 am #

Yes, we specify the shape of on sample, but always provide many samples, hence it is always 3d. Sorry for the confusion.

13. edwin October 8, 2019 at 7:58 am #

hi Jason, is there any way to pass two targets to the timeseriesgenerator, I mean, I have an input in my model and two target, it’s a classification problem with two outputs. Thanks.

14. Yusuf October 11, 2019 at 7:12 pm #

Hi Jason
I added a loop to your code with minor revision. I would like to forecast t+1 day(s) using multi-step forward. At validation step forecast values gone to +infinity or zero related to architecture. My full code at gist.github. Any suggestion?

”’
x1=495 # end of train period
valid=pred[x1:x1+n_input] # initial of validation = end of train period
print (valid,n_input, n_features)
for n_phase in range(0,n_valid-5):
x_input = valid[n_phase+0: n_phase+n_input].reshape((1, n_input, n_features))
yhat = model.predict(x_input, verbose=0)
valid=np.append (valid, yhat)
valid=valid[n_input:len(pred)-1]

• Jason Brownlee October 12, 2019 at 6:53 am #

Nice work.

• Yusuf October 12, 2019 at 4:32 pm #

Misunderstand me. Why forecast gone to infinity or zero? How can I correct te lstm architecture?

• Jason Brownlee October 13, 2019 at 8:26 am #

Perhaps you have a vanishing or exploding gradient?

Perhaps try scaling data prior to modeling?
Perhaps try using relu activation?
Perhaps try weight constraints?

15. Avram November 13, 2019 at 10:02 pm #

Hi Jason,
Is there a post of you doing data augmentation for time series prediction/classification in Keras?And also is this logical?

16. Arjun November 27, 2019 at 7:48 pm #

Hi jason,
I am currently working on a sales prediction project by using timeseriesgenerator.
Everything seems to be going well until the fitting part. It returns

AttributeError: ‘TimeseriesGenerator’ object has no attribute ‘shape’

the code is like this:

n_input = 30
n_features = 1
generator = TimeseriesGenerator(X_train,y_train,length = n_input,batch_size=16)
model = keras.models.Sequential()

when it reaches fitting it shows this error.
could you please tell what might be a possible reason behind it?

• Jason Brownlee November 28, 2019 at 6:33 am #

Looks like you are missing an “=” in the first hidden layer.

• Arjun November 28, 2019 at 3:00 pm #

sorry jason that was an error while copying the code.
the “=” is in the code snippet.

other than that what would you think the time series generator has a problem with accepting shape as attribute?

• Kaike January 17, 2020 at 12:19 pm #

I got the same error, how can I solve it?

• Jason Brownlee January 17, 2020 at 1:52 pm #

Try copying the code from the tutorial directly.

17. Ryan December 3, 2019 at 11:20 am #

Thanks Jason for the helpful tutorials!

I’m not seeing a keras’ function to normalize the generator’s output. Although I’d prefer to split the test/train sets with the generator – it seems one must first split, then normalize, then generate. Is that true?

Cheers

• Jason Brownlee December 3, 2019 at 1:33 pm #

Yes. Get the min/max or mean/stdev from train then apply scaling to train and test.

18. vusal December 13, 2019 at 3:32 am #

What about a trend or seasonal differencing with the generator?

• Jason Brownlee December 13, 2019 at 6:05 am #

Not that I’m aware of.