How to do it…

  1. Next, let's define the parameters to be used in our LSTM network, as well as the DataFrame where we are going to store the results:
n_lag = 1n_repeats = 30n_epochs = 1000n_batch = 4n_neurons = 3results = DataFrame()
  1. We then call the experiment method as follows:
results['results'] = experiment(series, n_lag, n_repeats, n_epochs, n_batch, n_neurons)

Inside the experiment() method, we process the data through the network as follows:

def experiment(series, n_lag, n_repeats, n_epochs, n_batch, n_neurons):  # method details ....
  1. First, we get the values of the series data frame as follows:
raw_values = series.valuesdiff_values = difference(raw_values, 1)

The output of the values of the series data frame is as follows:

raw_values ...

Get Keras Deep Learning Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.