Author

Topic: How to build a forecasting model using LSTM (Read 66 times)

hero member
Activity: 1078
Merit: 509
Leading Crypto Sports Betting & Casino Platform
February 22, 2022, 08:38:11 AM
#3
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.

No matter what model/algorithm you use, it's not reliable enough if all data you have is only past Bitcoin price. Without external data (such as sentiment about Bitcoin on twitter or latest news about Bitcoin), i expect people who use that model/algorithm could go bankrupt when something big happen (such as an exchange hacked and most funds stolen).

With the help of RNN the network can be predicted but it doesn't mean that the outcome will be correct at all time. The previous bitcoin price performance is the external data that will be used. However, RNN is compatible with speech and language or any sequential input. The bitcoin price can now be determined using the LSTM to keep track of the already saved prices inside the memory.
legendary
Activity: 2870
Merit: 7490
Crypto Swap Exchange
February 22, 2022, 08:29:56 AM
#2
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.

No matter what model/algorithm you use, it's not reliable enough if all data you have is only past Bitcoin price. Without external data (such as sentiment about Bitcoin on twitter or latest news about Bitcoin), i expect people who use that model/algorithm could go bankrupt when something big happen (such as an exchange hacked and most funds stolen).
hero member
Activity: 1078
Merit: 509
Leading Crypto Sports Betting & Casino Platform
February 22, 2022, 08:19:14 AM
#1
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)

Code:
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 Process

Code:
p = Poisson()
example, _ = p.generate(6)

plt.figure(figsize=(20,7))
plt.plot(example)

Result: []




Train LSTM Model on a Larger Data set


Code:
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


Code:
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

Code:
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)
Code:
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
Jump to: