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: [<matplotlib.lines.Line2D at 0x7feed62121d0>]
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FnSRhFnQ.png&t=665&c=FVRb65ncIyNXfA)
Train LSTM Model on a Larger Data sett1, _ = 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 varieda1, _ = 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 Predictionactual = 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: [<matplotlib.lines.Line2D at 0x7fef3f1acf50>]
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FlZI4s61.png&t=665&c=Ubn7RrCLkNnDNg)
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: [<matplotlib.lines.Line2D at 0x7feed003f410>]
![](https://ip.bitcointalk.org/?u=https%3A%2F%2Fi.imgur.com%2FsGndKHb.png&t=665&c=ogRdZKJ9JkDpSw)
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