A forecasting model helps in the forecasting of prices or even sales in an organization or company. But, it can also be used to forecast bitcoin prices with the help of RNN (Recurrent Neural Network) if you follow the steps in this
post you will gain the source code for predicting bitcoin Price which can then be implemented on the forecasting model.
But, this Model is general and not specifically meant for bitcoin price but the process is poison and the underlying process can be the prediction of the bitcoin price. So the aim is to be able to forecast values in poison process that has cyclic fluctuation in the underlying process. Poison process can be used to solve many mathematical problems in the blockchain Network. Since forecasting is based on determining DATA the model used by the
Author is
ARIMA and LTSM model which will help to forecast next actual data point.
Poison Modeling Using LSTM (Long Short Term Memory)import math
import numpy
import matplotlib.pyplot as plt
from src.poisson import Poisson
from src.lstm import LSTM
from sklearn.metrics import mean_squared_error
%matplotlib inline
%autosave False
Example Of Poison Processp = Poisson()
example, _ = p.generate(6)
plt.figure(figsize=(20,7))
plt.plot(example)
Result: [
]
Train LSTM Model on a Larger Data set
t1, _ = p.generate(10000)
t2, _ = p.generate(10000,2)
train = t1 + t2
l = LSTM()
l.train(train, 6)
Apply the LSTM model to a new data set that is more varied
a1, _ = p.generate(4)
a2, _ = p.generate(2,2)
a3, _ = p.generate(4)
a4, _ = p.generate(1,2)
actual = numpy.concatenate((a1,a2,a3,a4))
pred = l.predict(actual)
#pred = [x-8.5 for x in pred]
Plot The Prediction
actual = actual[72:-1]
error = math.sqrt(mean_squared_error(pred, actual))
plt.figure(figsize=(20,7))
plt.title('RMSE: {:.2f}'.format(error))
plt.plot(actual)
plt.plot(pred)
Result: []
Evaluate The Residual (The remaining values)
residual = []
for i in range(len(actual)):
val = actual[i] - pred[i]
residual.append(val)
plt.figure(figsize=(20,7))
plt.plot(residual)
Result: []
It's important to know that LSTM cannot function in all cases without a problem but, can be implemented on a less constrained data and it'll have lesser problems. While the ARIMA model performs better in forecasting data provided it remains compatible with the underlying process.
Source: https://github.com/ColinShaw/cyclic-poisson-forecasting-models/blob/master/LSTM.ipynb