Prediction

Since our RNN model is ready, we can consume it to make the prediction. We are going to use the price of today to predict the price of the next day. It is possible to predict for a longer span of time, but since there are a lot of influencing factors, longer-duration predictions end up having more errors:

# Make the predictions
test_set = dframe_test.values
inputs = np.reshape(test_set, (len(test_set), 1))
inputs = sc.transform(inputs)
inputs = np.reshape(inputs, (len(inputs), 1, 1))
predicted_BTC_price = regressor.predict(inputs)
predicted_BTC_price = sc.inverse_transform(predicted_BTC_price)

Now let's visualize our prediction by plotting them on a graph and comparing the differences:

# Visualize the results
plt.figure(figsize=(25,15), dpi=80, facecolor='w', edgecolor='k')
ax = plt.gca()
plt.plot(test_set, color = 'red', label = 'Real Bitcoin Price')
plt.plot(predicted_BTC_price, color = 'blue', label = 'Predicted Bitcoin Price')
plt.title('Bitcoin Price Prediction', fontsize=30)
dframe_test = dframe_test.reset_index()
x=dframe_test.index
labels = dframe_test['date']
plt.xticks(x, labels, rotation = 'vertical')
for tick in ax.xaxis.get_major_ticks():
tick.label1.set_fontsize(18)
for tick in ax.yaxis.get_major_ticks():
tick.label1.set_fontsize(18)
plt.xlabel('Time', fontsize=20)
plt.ylabel('BTC Price(USD)', fontsize=20)
plt.legend(loc=2, prop={'size': 25})
plt.show()

The output of the preceding snippet is given as follows:

Figure 12.10: Real price versus predicted Bitcoin price for a month

Figure 12.10 clearly shows that the difference is larger when the time is further to the training set. Go ahead and explore other types of algorithms on the training dataset; try to play around in order to get more ideas about why this is required. 

..................Content has been hidden....................

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