Preprocessing

Let's assume we want to predict the price for a month. We need to take a subset of the dataset for the last 30 days as test data. We can do that by splitting the dataframe:

# Split the dataset so that we can take last 30 days data as test dataset
prediction_days = 30
dframe_train= Real_Price[:len(Real_Price)-prediction_days]
dframe_test= Real_Price[len(Real_Price)-prediction_days:]

Now we have the test dataset. Let's normalize, reshape, and scale it:

# Data preprocessing 
training_set = dframe_train.values
training_set = np.reshape(training_set, (len(training_set), 1))

#import sklearn package and use MinMaxScaler
from sklearn.preprocessing import MinMaxScaler
sc = MinMaxScaler()
training_set = sc.fit_transform(training_set)
X_train = training_set[0:len(training_set)-1]
y_train = training_set[1:len(training_set)]
X_train = np.reshape(X_train, (len(X_train), 1, 1))
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.227.10.162