Here's the moment of truth: we are going to see if our model is able to give us a good prediction for the AAPL stock in 2017 and 2018.
We will perform a model evaluation using the mean squared error. Therefore, we will need to import the following library:
import sklearn.metrics as metrics
This section walks through visualizing and calculating the predicted vs. actual stock quotes for Apple in 2017 and 2018.
- Plot a side by side comparison of
Actual
versusPredicted
stock to compare trends using the following script:
plt.figure(figsize=(16,6)) plt.plot(combined_array[:,0],color='red', label='actual') plt.plot(combined_array[:,1],color='blue', label='predicted') plt.legend(loc = 'lower right') plt.title('2017 Actual vs. Predicted APPL Stock') plt.xlabel('Days') plt.ylabel('Scaled Quotes') plt.show()
- Calculate the mean squared error between the actual
ytest
versuspredicted
stock using the following script:
import sklearn.metrics as metrics np.sqrt...