scale data in - range scaler none if scalescaler=minmaxscaler(feature_range=( )train scaler fit_transform(traintest scaler transform(testsplit independent and dependent variables x_train train[::- y_train train[:- x_test test[::- y_test test[:- transforms for lstm input x_train np reshape(x_train(x_train shape[ ]x_train shape[ ] )x_test np reshape(x_test(x_test shape[ ]x_test shape[ ] )return x_train,y_train,x_test,y_test,scaler the function get_reg_train_test(also performs number of other optional preprocessing steps it allows us to smoothen the time series using rolling mean before the windowing is applied we can also normalize the data as well as scale based on requirements neural networks are sensitive to input values and it is generally advised to scale inputs before training the network for this use casewe will utilize the normalization of the time series whereinfor each windowevery time step is the percentage change from the first value in that window (we could also use scaling or both and repeat the processfor our casewe begin with window size of six days (you can experiment with smaller or larger windows and observe the differencethe following snippet uses the get_reg_train_test(function with normalization set to true in [ window pred_length int(window/ x_train,y_train,x_test,y_test,scaler get_reg_train_test(sp_close_seriessequence_length=window + roll_mean_window=nonenormalize=truescale=falsethis snippet creates seven-day window that is comprised of six days of historical data (x_trainand one-day forecast y_train the shapes of the train and test variables are as follows in [ print("x_train shape={}format(x_train shape)print("y_train shape={}format(y_train shape)print("x_test shape={}format(x_test shape)print("y_test shape={}format(y_test shape)