Bitcoin Price Prediction Using Machine Learning Models
Bitcoin Price Prediction Using Machine Learning Models
1. INTRODUCTION
1.1 Bitcoin
The outbreak of COVID-19 has impacted capital markets, including virtual currency
markets.[2] Describes the economic and social implications of the pandemic. The
study highlights the damage to global financial markets caused by the COVID-19
crisis and the role of the pandemic in the financial sector. Crypto-currency (i.e. BTC,
ETH, XRP) is associated with COVID-19 cases/fatalities. Initially, there was an
inverse correlation between Bitcoin and reported deaths/cases, but later on the
correlation becomes positive [3]. The primary question is whether Bitcoin is a Risky
hazard or a safe haven? What is the nature of Bitcoin during its destruction in
financial markets due to the COVID-19 pandemic? Conlon and McGee [4] addresses
both questions and show that Bitcoin does not behave as a safe haven, in fact, when
the crisis began, the movement of Bitcoin was similar to that of the S&P 500.
This paper uses various machine learning models to forecast daily Bitcoin prices. The
models used are Support Vector Machine (SVM), Linear Regression, Recurrent
Neural Network (RNN), Random Forest, Auto-Regressive Integrated Moving
Average (ARIMA), and Long Short Term Memory (LSTM). The overview of
research is shown in Figure 1
Linear Regression
Random Forest
Support Vector
Machine Machine Learning Bitcoin Price
Forecast
Models
RNN
LSTM
2. RELATED WORK
Due to the young age and high volatility, the study related to price prediction of
Bitcoin is lacking. Bitcoin because of its peer to peer system and decentralization has
attracted a large number of users all over the world.[7] The author found the link
between Twitter and Google search and Bitcoin price. The accuracy of Bitcoin price
prediction using polynomial regression is 77% per tweet volume and 66.66% with
Google trends. Chen [8] introduced the "latent source pattern" that has been
implemented by [9] to forecast the price of Bitcoin. There was an 89% return in fifty
days with a 4.10 Sharpe ratio. The research is also carried out to discover the effect of
mass media platforms on digital currency namely Bitcoin.[10] Analyzed the behavior
of a support vector machine, Artificial Neural Network, and Ensemble algorithm (k-
means clustering and recurrent neural networks). The support vector machine
algorithm has got the best results in price predictions. Machine learning patterns like
support vector machine, Random Forest, Long Short Term Memory, Quadratic
Discriminant Analysis, XGBoost were used for daily Bitcoin price prediction[11].
The support vector machine performed best with 65.5% accuracy. [12] studied the
influence of the most common edges of Bitcoin on price prediction and shows that a
single hidden layer feed-forward neural networks (SLFNs) obtained an accuracy of
60.05% (approximately).
[13] Predicted Bitcoin price using recurrent neural network and linear regression
model. The RNN model obtained the mean square error value below that of the
regression model due to its power to recognize long-term dependencies. In [14] the
linear regression, RNN and Random forest are compared. The RNN with LSTM has
increased the efficiency of the model for predicting Bitcoin prices, as the data is
highly volatile. The model resulted in an MAE of 0.0043, less than that of linear
regression and random forest. McNally compared the accuracy of the Automated
Regressive Integrated Moving Average (ARIMA), Recurrent Neural Network (RNN)
and Long Short Term Model (LSTM) models and achieved the highest accuracy of
52% using the Long Short Term Memory network. Ladislav[16] studied the relation
between the price of Bitcoins and Wikipedia and Google searches. The results also
showed the imbalance between the heightened interest in crypto-currency while in
trends the value is lower or higher. [17] used the ARIMA model for short-term
forecasts.ARIMA (4,1,4) predicts the Bitcoin price more accurately. The average
absolute error generated was 0.87 for the Day One forecast and 5.98 for the Day
Seven forecasts. Consequently, ARIMA has produced better short-term outcomes.
3. METHODOLOGY
The Bitcoin data set comes from an online community called Kaggle. This dataset is
from October 8, 2015 to April 10, 2020. Each row includes Close, Date, High,
Volume BTC, Low, Volume USD and Opening price of BTC.
Features Explanation
Date Bitcoin price for particular Date
Open Opening Price
Close Closing Price at that day
High High Price
Low Low Price
Volume Volume from top Exchange
Table 1 Features of dataset
3.3 Modelling
Data Mining is about extracting useful information from the data. The technical basis
for data extraction is given by machine learning. Thus, Machine Learning(ML) is a
subset of Artificial Intelligence(AI) in which the machine learns automatically from
the previous experience but is not explicitly programmed. A data set is composed of
instances consisting of one or several attributes. Machine learning is generally two-
fold: supervised machine learning and non-supervised machine learning. Supervised
Learning models the dataset with labels. x and y can be used as a representation of
each instance, x is a set of independent variables, and y is a set of dependent
attributes. The target variable may be discrete or continuous. If the target attribute is
continuous then the regression model is used else if discrete then the classification
model is applied. Examples of supervised learning are support vector machines and
neural networks. Unsupervised learning is where the model learns from observations
and discovers structures within the data set. It is used for modeling the data set where
the attribute is unknown. The objective of this research is to predict Bitcoin prices. As
such, the purpose is known so that supervised machine learning will be used. The
algorithms used are Random Forest, Linear regression, SVM, ARIMA, LSTM and
RNN.
Linear regression reveals the relation between dependent and independent variables.
The equation for line fitting data points is as follow:
Y=a+bX (1)
‘X’ denotes an independent variable, ‘Y’ denotes a dependent variable, ‘b’ denotes
the slope, and ‘a’ denotes intercept.
Random Forest is one of the popular regression and classification problems. It merges
multiple decision trees for better outcomes. Decision trees address a number of
classification issues. The decision tree is like a tree structure where feature space is
partitioned recursively. Recursion is terminated when partitioning adds no value to
the forecast or until single class samples are present in each node. In case of decision
trees the dataset can be linked to leaf nodes.
SVM model is used in Binary classification issues [11]. The idea is to discover a
hyperplane so that there is a maximum margin between two classes of data samples.
Assume there is a binary classification issue. m is the number of data points within
the actual n-dimensional space.
x.y + a = 0 (2)
Where ‘y’ belongs to Rn, ‘a’ belongs to R,’y’ is the weight vector that is normal to the
hyperplane, ‘a’ is bias. The best hyperplane is achieved with minimization of ||w||.
J.L.Elman developed Recurrent Neural Networks (RNNs). These are the kinds of
neural networks in which signals can move both backward and forward in a repetitive
manner. These networks consist of the context layer. Every layer output is transferred
to the context layer and then fed to the adjacent layer as input. At every timestamp,
the state is rewritten.
The Long Short Term Memory (LSTM) model solves the vanishing gradient problem
of the RNN. LSTM contains three gates, namely: output gate, forget gate, and input
gate [11].In the case of sequence data,LSTM performs better in extracting long term
dependencies and in representing both future and historic information.
ht-1 ht ht+1
A tanh A
σ σ tanh σ
h
Xt-1 Xt
Xt+1
Here xt is input at time t; ht is a hidden state at time t; Wo, Wc, Wf, Wi are weight
matrix, bc, bi, bf, and bo are the offset of LSTM. £ is the function of activation; ʘ is
the dot matrix multiplying operator.
AR(p)+MA(q)=ARIMA(p, d, q)
Auto Regression (AR) is used to look for the correlation between the previous and the
current period. The ARIMA (p,0,0) is:
The moving mean (MA) indicates the movement of the previous error values.
Therefore, the ARIMA (0,0,q) is :
4. IMPLEMENTATION
The dataset was divided into 80% training and 20% testing and the Bitcoin price was
predicted for the next thirty days. The actual and predicted graphs are shown
following:
5. EVALUATION
MAPE is the mean of the absolute difference between original and predicted values.
It is the measurement of the correctness of a forecasting system.
100 𝑎𝑐𝑡𝑢𝑎𝑙 𝑖−𝑝𝑟𝑒𝑑𝑖𝑐𝑡𝑒𝑑 𝑖
MAPE = ∑𝑛𝑖=1 | |
𝑛 𝑎𝑐𝑡𝑢𝑎𝑙 𝑖
RMSPE tells about the percentage of error with respect to actual values.
6. RESULTS
The purpose of research is to evaluate different models of the machine learning for
Bitcoin price prediction. Table 2 shows the results by running Linear regression,
Random Forest, Support Vector Machine, ARIMA, LSTM and RNN models. The
recurrent neural network achieved the best result with the Mean Absolute Percentage
Error of 0.3174 and RMSPE of 0.8853.
45
40
35
30
25
MAPE
20
RMSPE
15
10
0
Linear Random SVM RNN LSTM ARIMA
Regression Forest
The crypto-currency market is booming and has drawn attention from entrepreneurs
and investors in recent years.By providing comparative studies and conclusions based
on Bitcoin price data, it will further assist in understanding the difficult and rapidly
expanding market.In conclusion, this study focuses on the use of machine learning
models to forecast Bitcoin price.The Google Colaboratory was used for the
implementation of the Bitcoin dataset.Further work can examine other datasets,
including more features that could help predict most precise and reliable Bitcoin price
References
[2] Goodell, J.W,”COVID-19 and finance: Agendas for future research”, Finance
Research Letters 35 (2020), pp. 101512
[4]Colon & Mc Gee, R.J. (2020),”Safe haven or risky hazard? Bitcoin during the
COVID-19 bear market”, Finance Research Letters, 35 (2020), pp. 101607
[10] D.C.A. Mallqui and R.A.S. Fernandes, ”Predicting the direction, maximum,
minimum and closing prices of daily Bitcoin exchange rate using machine learning
techniques”, Applied Soft Computing Journal (2018),
https://doi.org/10.1016/j.asoc.2018.11.038
[11] Zheshi Chen, Chunhong Li, Wenjun Sun,”Bitcoin price prediction using
machine learning: An approach to sample dimension engineering”, Journal of
Computational and Applied Mathematics 365 (2020) 112395
[12] Marcell Tamas Kurbucz,”Predicting the price of Bitcoin by the most frequent
edges of its transaction network.” Economics Letters 184 (2019) 108655.
[13] H. Kavitha, U.K. Sinha and S.S. Jain, “Performance Evaluation Of Machine
learning Algorithms for Bitcoin Price Prediction”, Fourth International Conference on
Inventive Systems and Control (ICISC), 2020, pp. 110-114
[15] S. McNally, J. Roche and S. Caton,“ Predicting the price of Bitcoin Using
Machine Learning”, 26th Euromicro International Conference on Parallel, Distributed
and Network-based Processing (PDP), 2018, pp. 339-343