alexander34ro / AML-Replicating-Novel-Deep-Learning-with-CNN-and-Bi-Directional-LSTM-for-Improved-Index-Prediction

Apache License 2.0
0 stars 0 forks source link

Extract the data #1

Closed alexander34ro closed 3 years ago

alexander34ro commented 3 years ago
  1. Import data in pandas using the S&P500 dataset (keep only
  2. Split data into 50 days series, each series starts 1 day after the previous one
  3. Normalize (subtract 1st, divide by 1st)

Normalize:

x = np.random.rand(1000)*10
norm1 = x / np.linalg.norm(x)
alexander34ro commented 3 years ago
(x - x[0]) / x[0]
alexander34ro commented 3 years ago
sequences = []
for i in (0...N-50):
  sequences.push(data[i:i+50])
ariansajina commented 3 years ago

To construct the sequences we could do like this: timeseries is a numpy array

sequence_ix = [range(i, i+sequence_length) for i in range(timeseries_length - sequence_length + 1)]
sequences = [timeseries[ix] for ix in sequence_ix]