Time Series Analysis of Cryptocurrencies Using Deep Learning & Fbprophet

Understanding various cryptocurrencies and predicting them using Machine Learning & Deep Learning

Yash Indulkar
Apr 25 · 11 min read
Photo by Tech Daily on Unsplash

Important Points

  1. This paper consists of cryptocurrency prediction and analysis using different algorithms, the major cryptocurrency took into account for analysis and prediction are Bitcoin (BTC), Ethereum (ETH), Chainlink (LINK), Bitcoin Cash (BTC), XRP (XRP).
  2. Prediction of cryptocurrencies is tangible and requires lots of understanding regarding the flow of money on daily basis.
  3. The machine learning industry has advanced to a great extent and it would further do, this advancement has led us to a bigger problem-solving technique, that is prediction of data or analysis of trend which can be in any format.
  4. The algorithms used for such analysis is LSTM (Long Short-Term Memory) which is part of Deep Learning and further Fbprophet which is an Auto Machine Learning for prediction is used.
  5. The metric used for the analysis of the algorithm is MAE (Mean Absolute Error). The programming language used is Python, which solves the majority of use cases.

INTRODUCTION

Artificial Intelligence is the root of both machine learning & deep learning, machine learning is a subset of artificial intelligence and deep learning is a subset of machine learning in that flow. Deep learning plays an important role in the advancement of artificial intelligence in many ways, using such an important feature for the prediction of data on daily basis gives better results and also helps in the understanding of various neglected sides. The cryptocurrency has been evolved and grown to a very large amount, estimating to a billion-dollar industry. Understanding such huge digital currency is difficult and also to estimate the change in trend is important, as a change in trend can lead to profit or loss of a particular cryptocurrency. The number of cryptocurrencies over the year has increased with new currency coming out, this introduction of digital currency can tell the demand of them in the market, due to the non-presence of such currency it becomes difficult to track the change, this is where deep learning would come in handy. Deep Learning not only predicts the high-low of any currency but tells the change in trend over the month, week, or day depending on the datasets provided. Time series analysis has been used for analyzing different digital currencies and providing estimation based on the daily report of a particular currency. The cryptocurrency used is Bitcoin (BTC), Ethereum (ETH), Chainlink (LINK), Bitcoin Cash (BTC), XRP (XRP). These currencies have different values based on the popularity of each cryptocurrency; estimation of these values may vary depending on each one of them. The deep learning algorithm used for the analysis of such digital currency is LSTM, it stands for Long Short-Term Memory which is a special RNN (Recurrent Neural Network). Unlike the feed-forward neural network, the LSTM has a feedback connection which makes it special. The other automatic forecasting procedure used is Fbprophet which is an auto machine learning for prediction of data based on events, which fits the datasets based on a linear model, that can shift the model to nonlinear or logistics growth with tweaking of arguments.

LITERATURE REVIEW

Digital currency has been increased over the past years, following the trend back to the year it started, it can be observed that cryptocurrencies got bigger and bigger with huge market values. Analysis of this cryptocurrency with precise prediction is important to keep up with the growing industry. The time series analysis plays an important role which can be tracked back when the paper “Forecasting cryptocurrency prices time series using machine learning approach.”, was published in the year 2019 by Derbentsev, Vasily, it showed a significant change in the understanding of market values for cryptocurrency, which cleared all the doubts related to the machine learning concept [3]. The flow of such information was useful for making the base stronger with understanding the concepts. The other paper “Forecasting cryptocurrency returns and volume using search engines.”, was published in the same year that was 2019, which showed the cryptocurrency price forecasting with the volume as a category using a search engine. This cleared the concepts of various trends related to the digital currency and as volume was directly related to the increase in price or vice-versa. Machine Learning plays an important role in the better understanding of concepts related to artificial intelligence, that can be submerged with the use of Deep Learning [7]. This particular concept of analysis deep learning for the forecasting of data based on various algorithms was cleared with the paper that was “Ensemble Deep Learning Models for Forecasting Cryptocurrency Time-Series.”, which was published in the year 2020 [4]. This particular research paper used the concept of deep learning for the analysis of time series for cryptocurrency. Deep Learning concept can be difficult with approach related to different algorithms that may differ from machine learning, it is important to build a proper model that may depict the values for the change related to series of dates, this particular helped in the understanding of such important criteria. The other approach that was related to the auto-machine learning algorithm that was used to cover the problem related to seasonality, this problem was important to overcome the time series prediction of data [1]. The paper published as “Software defect trend forecasting in open-source projects using a univariate ARIMA model and Fbprophet.”, solved the queries related to the particular model that was published in 2020 [5].

METHODOLOGY

This section of the article deals with different methods used to obtain the desired outputs which are explained in the experimental results. The methodology is divided into 2 sub-sections that are:

Long Short Term Memory Algorithm

Fbprophet

EXPERIMENTAL RESULTS

The experimental section of this research paper consists of various tests and results obtained by performing iterations. This paper consists of an analysis of cryptocurrency based on time series data which was extracted using JSON in python by web-scraping the data from, Coin Market. The steps followed for the time series analysis can be understood in Fig below.

Time Series Architecture for various Trends- Image by Author
Dataset Used for Analysis & Prediction from Moneycontrol.com- Image by Author

The datasets were bifurcated into training & testing with an 80–20 ratio, 80 % was for the training purpose, and the remaining 20 % was for testing purposes.

Training & Testing Bifurcation of Datasets- Image by Author

The algorithm used for the time series analysis is LSTM which is a smart RNN, this particular model is considered because of its feedback capability. The long Short-Term Memory model was created based on different parameters, the parameters that were included in this neural network are Input Layer, Hidden Layer & the Output Layer, the summary for the model created in time series analysis can be seen in Fig below.

Simple LSTM Algorithm used for prediction- Image by Author

It can be observed that the sequential model has 1-layer for the input with 100 input nodes that are connected to the dropout layer of 0.2 to avoid the overfitting of the model which is densely connected to the last layer which has the activation function as Linear. The optimizer used for the model was Adam & the loss function respectively was MSE (Mean Squared Error). The model was fitted for the training data with epochs of 20 and batch size of 32 respectively. The actual data points to the predicted data points are directly proportional to the MAE (Mean Absolute Error). The Mean Absolute Error can be calculated based on the prediction, true values & total data points. The lower the MAE value, the better-predicted results are obtained and vice-versa.

The prediction for each cryptocurrency can be seen from Fig respectively, which shows the actual & the predicted plots for the different cryptocurrencies based on the training data and understanding of the model, that was trained for analysis.

Bitcoin Vs Bitcoin Cash Prediction- Image by Author
Ethereum Vs Chainlink Prediction- Image by Author
XRP Price Prediction- Image by Author

The other approach for the time series analysis was based on Fbprophet which is an auto machine learning algorithm to work with the seasonality of datasets. In this research, the seasonality was daily & yearly, which was used for the analysis of the trend based on the cryptocurrency’s datasets. The plot below shows the prediction of dates based on the training datasets, the period that was applied for all the predictions was of 15 days. The fig below is a plot for Bitcoin Cryptocurrency, Bitcoin Cash, Ethereum, Chainlink & XRP Cryptocurrencies respectively.

Bitcoin Vs Bitcoin Cash Fbprophet Prediction- Image by Author
Ethereum Vs Chainlink Fbprophet Prediction- Image by Author
XRP Fbprophet Prediction- Image by Author

Similarly, the Fbprophet provides different components on which the trend can be analyzed, it varies from daily, monthly, weekly & yearly, which helps to avoid seasonality. Seasonality is something that occurs based on the same frequency, the best example for it would be “Price of Ice-cream in the season of summer vs the price of Ice-cream in the season of Winter”. The seasonality plots for trend analysis can be observed from fig below.

Bitcoin Yearly Vs Daily Component Prediction with Fbprophet- Image by Author
Bitcoin Cash Yearly Vs Daily Component Prediction with Fbprophet- Image by Author
Ethereum Yearly Vs Daily Component Prediction with Fbprophet- Image by Author
Chainlink Yearly Vs Daily Component Prediction with Fbprophet- Image by Author
XRP Yearly Vs Daily Component Prediction with Fbprophet- Image by Author

Mean Absolute Error for each cryptocurrency is the metric applied for the understanding of change in datasets based on variation, the variation is the time. The different values for error based on different datasets are responsible for the change in actual data points to that of predicted data points. This change in MAE values for training & validation datasets can be understood by Fig below.

Mean Absolute Error Vs Cryptocurrency- Image by Author

It can be observed that in the above figure, the highest MAE validation score was achieved by Chainlink, followed by Ethereum & Bitcoin Cash. Similarly, the highest MAE Training score was achieved by Ethereum & Chainlink respectively. The higher MAE, the more difference between the actual & predicted values & vice versa.

CONCLUSION

The study aims to understand the time series analysis of different cryptocurrencies based on the seasonality of datasets. The algorithm used for such analysis is LSTM & the other approach used is Fbprophet. The metric used for the evaluation of the score is MAE, this score was generated for all the cryptocurrencies which showed that the lower the value the better the prediction of the validation dataset. With this experiment, it was observed that the lowest error value was generated for the Bitcoin cryptocurrency that was 0.01867 followed by the Bitcoin Cash that was 0.02632. The plot based on the actual data points to that of predicted data points was identical to both the above cryptocurrencies due to the lower MAE score. This means that the trained model fitted best for both the digital currency as the error rate was low as compared to others. The other prediction approach used was the Fbprophet model which is an auto machine learning model, used for prediction and understanding the change in trend based on seasonality, the seasonality in this research was daily. This showed the prediction of every cryptocurrency for 15 days post.

REFERENCES

[1] Catania, Leopoldo, and Stefano Grassi. “Modelling crypto-currencies financial time-series.” Available at SSRN 3028486 (2017).

[2] Catania, Leopoldo, Stefano Grassi, and Francesco Ravazzolo. “Predicting the volatility of cryptocurrency time-series.” Mathematical and Statistical Methods for Actuarial Sciences and Finance. Springer, Cham, 2018. 203–207.

[3] Derbentsev, Vasily, et al. “Forecasting cryptocurrency prices time series using machine learning approach.” SHS Web of Conferences. Vol. 65. EDP Sciences, 2019.

[4] Livieris, Ioannis E., et al. “Ensemble Deep Learning Models for Forecasting Cryptocurrency Time-Series.” Algorithms 13.5 (2020): 121.

[5] Shrove, Michael Thomas, and Emil Jovanov. “Software defect trend forecasting in open source projects using a univariate ARIMA model and FBProphet.” Int. J. Softw. Eng. 8.1 (2020): 1–15.

[6] Mazed, Mashtura. Stock price prediction using time series data. Diss. Brac University, 2019.

[7] Adur Kannan, Bhuvana, et al. “Forecasting Spare Parts Sporadic Demand Using Traditional Methods and Machine Learning-a Comparative Study.” SMU Data Science Review 3.2 (2020): 9.

[8] Mensi, Walid, Khamis Hamed Al-Yahyaee, and Sang Hoon Kang. “Structural breaks and double long memory of cryptocurrency prices: A comparative analysis from Bitcoin and Ethereum.” Finance Research Letters 29 (2019): 222–230.

BEFORE YOU GO

Research Paper: https://ieeexplore.ieee.org/document/9397004

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data…

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Yash Indulkar

Written by

Machine Learning | Deep Learning | Thakur College of Science & Commerce Github | Linkedin : Yashindulkar Website : https://yashindulkar.github.io/

Analytics Vidhya

Analytics Vidhya is a community of Analytics and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Start a blog

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store