Login using Social Account
     Continue with GoogleLogin using your credentials
Let us now plot the predicted stock prices vs the actual ground truth values.
We shall use model.predict()
to get the predicted values of the test data set.
Use predict
method on model
and pass testX
as the argument.
pred = model.<< your code comes here >>
Since we have scaled the actual values of the dataset, we need to inverse transform the values. So, inverse transform the predicted values using scaler.inverse_transform()
and pass the pred
as an argument.
pred = << your code comes here >>(pred)
print(pred[:10])
Now, reshape the test set and inverse transform the test set values.
testY_actual = testY.reshape(testY.shape[0] , 1)
testY_actual = scaler.inverse_transform(testY_actual)
print(testY_actual[:10])
Let us now use pred
and testY_actual
and visualize their graphs to depict the predicted and actual values with respect to time.
plt.plot(testY_actual , 'b')
plt.plot(pred , 'r')
plt.xlabel('Time')
plt.ylabel('Stock Prices')
plt.title('Check the performance of the model with time')
plt.legend(['Actual', 'Predicted'], loc='upper left')
plt.grid(True)
plt.show()
Taking you to the next topic in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...