Investing in Cryptocurrencies with RNN’s – Elias Kountouris
The cryptocurrencies market is ridiculously unstable. Prices of even the most popular coins fluctuate by large margins. It almost seems foolish to invest in them. Is there a way for people to reliably invest in any cryptocurrency?
While people may have their doubts, there is one way to predict what will happen to the cryptocurrencies price, and it’s been proven to work with the stock market!
Once again, AI seems to offer the best solution to this problem. I created a model that takes data from the coin’s history and uses it to predict price changes in the future. It then advises you when you should invest in the coin.
The best model for this task is a Recurrent Neural Networks (RNN). These networks are really good at analyzing sequential data. Sequential data is data that has some sort of order to it. It can come in many different forms. Speach, text, music and obviously cryptocurrency prices are all good examples of sequential data.
The property of sequential data that makes it unique is that it, to no one’s surprise, comes in a sequence. In many examples the independent variable that it is sequenced against is time. When it comes to stocks and cryptocurrency evaluation, you have the price values plotted along time, and the price at a given time will directly affect the price in the seconds following it.
To create a model that employs this concept, information for the previous nodes must be passed into the following nodes. Then the output from that node must be passed into the next node and so on. The output that is actually used will be the last output.
To make my model I used a data set that had the information for 4 different cryptocurrencies, Bitcoin, Etherium, Litecoin and Bitcoin Cash. Like in many AI projects, most of the code is devoted to the preprocessing of the data. One of the preprocessing steps we do is normalizing the data. This means bringing all the values to an average value.
Here is an example of why normalizing is important:
Bitcoin might be at $9000 while Etherium is only at around $200. A $500 change in Bitcoin would appear as a bigger change than a $10 dollar change in Etherium to our model, but they are both only a 5% change for their respective coin. If we want to train our model off of both coin’s data, it needs to look at a 5% change as just that and ignore the actual number. This means we must average the numbers out so that a 5% change is the same number in both instances.
We also must split up our data between test and training data. This is to prevent overfitting, which is when a model becomes too accustomed to the data it is being trained on and has very high accuracy but only for that specific data set.
Model
The model has 12 layers in it and was built using Keras. I won’t dive into the ordering of the layers, but I will explain what each type of layer does.
LSTM
Long-Short-Term-Memory layers are essentially the RNN part of our code. They can take previous outputs and use them as inputs.
Dropout
Dropout layers will randomly deactivate certain layers in the neural network. The reason we do this is to prevent overfitting and to force our model to find more ways to estimate our data.
Batch Normalization
This is very similar to normalization for the data, which was explained earlier. Here we try to normalize the output of the previous activation layer. This results in more stable results and faster training times.
Dense
Dense layers are just another way of saying non-linear activation functions. We use two different types of functions for our model, softmax, and ReLu.
AI
Published at Sun, 15 Dec 2019 03:47:06 +0000
{flickr|100|campaign}
