Skip to content

Instantly share code, notes, and snippets.

@ashwinprasadme
Last active December 14, 2020 16:45
Show Gist options
  • Save ashwinprasadme/9879ffe47df0fb8ef0cb96909b479cfc to your computer and use it in GitHub Desktop.
Save ashwinprasadme/9879ffe47df0fb8ef0cb96909b479cfc to your computer and use it in GitHub Desktop.
#Create the testing data set
#Create a new array containing scaled values from index 1543 to 2002
test_data = scaled_data[training_data_len - 60: , :]
#Create the data sets x_test and y_test
x_test = []
y_test = dataset[training_data_len:, :]
for i in range(60, len(test_data)):
x_test.append(test_data[i-60:i, 0])
# Convert the data to a numpy array
x_test = np.array(x_test)
# Reshape the data
x_test = np.reshape(x_test, (x_test.shape[0], x_test.shape[1], 1 ))
# Now to get the test set ready in a similar way as the training set.
# The following has been done so forst 60 entires of test set have 60 previous values which is impossible to get unless we take the whole
# 'High' attribute data for processing
dataset_total = pd.concat((dataset["High"][:'2016'],dataset["High"]['2017':]),axis=0)
inputs = dataset_total[len(dataset_total)-len(test_set) - 60:].values
inputs = inputs.reshape(-1,1)
inputs = sc.transform(inputs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment