# Set window of past points for LSTM model window = 10 # Split 80/20 into train/test data last = int(n/5.0) Xtrain = X[:-last] Xtest = X[-last-window:] # Store window number of points as a sequence xin = [] next_X = [] for i in range(window,len(Xtrain)): xin.append(Xtrain[i-window:i]) next_X.append(Xtrain[i]) # Reshape data to format for LSTM xin, next_X = np.array(xin), np.array(next_X) xin = xin.reshape(xin.shape[0], xin.shape[1], 1)