Bitcoin Forum
May 06, 2024, 04:40:52 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to build a forecasting model using LSTM  (Read 66 times)
Accardo (OP)
Hero Member
*****
Offline Offline

Activity: 1078
Merit: 510


Leading Crypto Sports Betting & Casino Platform


View Profile
February 22, 2022, 12:19:14 PM
Last edit: February 22, 2022, 12:39:16 PM by Accardo
 #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: [<matplotlib.lines.Line2D at 0x7feed62121d0>]




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: [<matplotlib.lines.Line2D at 0x7fef3f1acf50>]



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: [<matplotlib.lines.Line2D at 0x7feed003f410>]



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

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714970452
Hero Member
*
Offline Offline

Posts: 1714970452

View Profile Personal Message (Offline)

Ignore
1714970452
Reply with quote  #2

1714970452
Report to moderator
1714970452
Hero Member
*
Offline Offline

Posts: 1714970452

View Profile Personal Message (Offline)

Ignore
1714970452
Reply with quote  #2

1714970452
Report to moderator
1714970452
Hero Member
*
Offline Offline

Posts: 1714970452

View Profile Personal Message (Offline)

Ignore
1714970452
Reply with quote  #2

1714970452
Report to moderator
ABCbits
Legendary
*
Offline Offline

Activity: 2870
Merit: 7464


Crypto Swap Exchange


View Profile
February 22, 2022, 12:29:56 PM
Merited by Accardo (2)
 #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).

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Accardo (OP)
Hero Member
*****
Offline Offline

Activity: 1078
Merit: 510


Leading Crypto Sports Betting & Casino Platform


View Profile
February 22, 2022, 12:38:11 PM
 #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.

..Stake.com..   ▄████████████████████████████████████▄
   ██ ▄▄▄▄▄▄▄▄▄▄            ▄▄▄▄▄▄▄▄▄▄ ██  ▄████▄
   ██ ▀▀▀▀▀▀▀▀▀▀ ██████████ ▀▀▀▀▀▀▀▀▀▀ ██  ██████
   ██ ██████████ ██      ██ ██████████ ██   ▀██▀
   ██ ██      ██ ██████  ██ ██      ██ ██    ██
   ██ ██████  ██ █████  ███ ██████  ██ ████▄ ██
   ██ █████  ███ ████  ████ █████  ███ ████████
   ██ ████  ████ ██████████ ████  ████ ████▀
   ██ ██████████ ▄▄▄▄▄▄▄▄▄▄ ██████████ ██
   ██            ▀▀▀▀▀▀▀▀▀▀            ██ 
   ▀█████████▀ ▄████████████▄ ▀█████████▀
  ▄▄▄▄▄▄▄▄▄▄▄▄███  ██  ██  ███▄▄▄▄▄▄▄▄▄▄▄▄
 ██████████████████████████████████████████
▄▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄
█  ▄▀▄             █▀▀█▀▄▄
█  █▀█             █  ▐  ▐▌
█       ▄██▄       █  ▌  █
█     ▄██████▄     █  ▌ ▐▌
█    ██████████    █ ▐  █
█   ▐██████████▌   █ ▐ ▐▌
█    ▀▀██████▀▀    █ ▌ █
█     ▄▄▄██▄▄▄     █ ▌▐▌
█                  █▐ █
█                  █▐▐▌
█                  █▐█
▀▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▀█
▄▄█████████▄▄
▄██▀▀▀▀█████▀▀▀▀██▄
▄█▀       ▐█▌       ▀█▄
██         ▐█▌         ██
████▄     ▄█████▄     ▄████
████████▄███████████▄████████
███▀    █████████████    ▀███
██       ███████████       ██
▀█▄       █████████       ▄█▀
▀█▄    ▄██▀▀▀▀▀▀▀██▄  ▄▄▄█▀
▀███████         ███████▀
▀█████▄       ▄█████▀
▀▀▀███▄▄▄███▀▀▀
..PLAY NOW..
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!