CRYPTOIntel
By: Mehak Parashar
Tags: Machine Learning, Bitcoin, Crytocurrency, Data Science, Big Data

4. Methodology

4.1 EDA

The market value price of cryptocurrencies has been rapidly oscillating every day even for the oldest cryptocurrency in the market bitcoin. The data analysis for market price on top ten cryptocurrencies currently shows that when the bitcoin was in the initial stages the price was very low. Bitcoin reached the peak market value price around 19,000 USD in 2017 as shown in figure 4. The other cryptocurrencies have been in the market very recently and the prices are not very low when compared to the bitcoin. Bitcoin Cash and Ethereum are among other top currencies that show rapid growth in the last couple of years. It can also be seen the price value of bitcoin going down after 2017, which questions whether Bitcoin is a bubble?

Figure 4 — Cryptocurrency Market Price (USD)

Figure 5 represents the price fluctuations that is the difference between the opening and closing price for top cryptocurrencies. The year 2017 was a breakthrough since the price of bitcoin was increasing rapidly during this time frame.

Figure 5 — Change in price of different cryptocurrencies

Plots in figure 6 show the change in the price of the top ten cryptocurrencies over 24 hours and the pie chart representing the market capitalization of different cryptocurrencies.

Figure 6–24 Hour Change Trends and Market Cap

4.2 Neural Networks (Machine Learning)

As discussed before we have to neural networks in place for prediction, which are discussed in detail below.

4.2.1 Numerical Model

Cryptocurrencies are the future of currencies. With its increase in popularity, more and more people want to invest in it. To forecast the price of the next day based on historical data we used Deep Neural Networks framework. Particularly LSTM Long (short-term memory), a type of Recurrent neural network from Keras as they have been proven to work really well for regression problems. The price of the cryptocurrencies depends upon a lot of factors, we used close, high, low, open, volumefrom, volumeto and we used OHLC to calculate the average price for that day and used it as an input to our model. Since we considered market volume as a factor to be used in our model, which had the highest value among all the variables. We normalized the data using scikit-learn’s minmax normalization module with a standard deviation of one. Since predicting the price is of time series type, we shifted each of the average prices we calculated, to one step forward in time and removed the nan values. After the data was ready, we split the data into train set (80%) and test set (20%). After transforming the data into three-dimensional shape, we used Keras framework to build, train predict the average price of the cryptocurrency.

Figure 7 — Train and Test Loss

In our LSTM we used 80 neurons, 2 layers and trained our model for 50 epochs using ADAM Optimizer as an optimization method since it adapts the learning rates based on the average of the first moment and the average of the second moment while training the model and the Mean Absolute Error loss as a loss function as shown in figure 7.

We validated the model on the test set and calculated Root Mean Square Error on both training and testing set results.

4.2.2 Numerical + Sentiment Model (For Bitcoin only)

Does News speculations play an important role when there is an increase or decrease in the price of Bitcoin? And Can we predict the future price using numerical historical along with news sentiment? To answer this, we scrapped the new articles related to bitcoin from 2017 and performed NLP techniques for cleaning the title and body of the news articles and calculated its sentiment polarity using Spark’s MLib. We summed the sentiment over all the news articles for that day and finally concatenated to the historical data from 2017. This sentiment polarity was a new feature which was added. The same above process was followed to train and test model. We were then successfully able to predict the price of the bitcoin using OHLCV and news sentiment polarity.

4.2.3 Topic Modeling

Knowing what people talking about cryptocurrencies and understanding their problems and opinions is a critical aspect. To answer this, we performed topic modeling using LDA (Latent Dirichlet Allocation) from Gensim package on huge news articles which were scrapped to uncover the hidden structure from the collection of news articles to discover the trends in the social media news. Data cleaning was performed to remove punctuations, extra spaces, and stopwords [2]. We performed text pre-processing using spacy(spaCy) and later lemmatization. Finally, trained the data set on the LDA model for the top 10 top topics. This was visualized using pyLDAvis package for the interactive chart and was embedded in the web front end as shown in figure 8. We finally visualized an interactive topic modeling of various models where the user can predefine the topic to be selected and also adjust the alpha value.