Predicting Bitcoin Price using *DEEP* Learning in 2021 [PART 2/2]ūüĒī

3 2 1 go… Follow the captions to learn more hello everyone I’m Ritvik Dashora and I’m 
back with a new video on some new learnings   this is the part two of uh the prediction of 
the bitcoin prices using deep learning model   and you can see that I have the code in front 
of me and in the last video on sunday we posted   this video where we made this model LSTM 
based model you can see that these are the   the the model training results over this and 
now in this video I’m going to use this model   to make the actual prediction and make a graph 
of prediction versus the actual prices so let's   go just just to give a very very brief idea we 
actually used 12 data API in the last video to   extract the prices we use five minutes interval 
we trained the model using two hours of recurring   data and then we are predicting the next hour 
price of bitcoin we use lst model for this one   and the libraries that we have used are all this 
one and this was the quiz in the last video you   can still write your option in the comment section 
below let's see how many of you guys actually know   the correct answer so guys the way we actually 
extracted the bitcoin prices using 12 data API   like this one we actually use a an API key over 
there and then we did all those things we made the   API URL and then finally we used a request library 
to get the final prices if you remember I said   this thing in my last video is that I’m actually 
keeping from 20th to 24th 23rd prices as my   reserve for my testing purpose and that's why 
actually I didn't train it on that data because   it's it's not a good activity it's not a good 
procedure to actually train and test data on   the same data set and that's why actually I didn't 
use in any of those data for the training purposes   now I have actually made the same way which is 
test start and test and and now I’m using it from   20th of october to 23rd of october right it's the 
same API URL over there I’m using request library   and then using the final pd.data frame to get to 
the final test data file you can see that we have   another data frame in front of us of bitcoin 
prices from 20th of october to 23rd of october   we have 855 rows with us and five columns 
I and I’ll be just using this close column   for this purpose so let's see what is the closing 
price of this so this and then if I do it like   this the close is like you can see it's it's 
a panda series the only issue is that it's in   the object format I’ll have to convert it into 
the float format and that was actually the quiz   so yeah I I’m going to use it like this 
so pd dot to numeric like this so if we   if we run it you can see that it has converted the 
type into float now I’m just interested in values   perfect so we have all the values now in front of 
us let's call this as bitcoin prices these are the   actual values of bitcoin right so I’ll be using 
this to plot the graph now these are the actual   prices now we will have to get the prediction 
predicted prices as well so that we have   both bitcoin prices in the predicted prices in 
the graph so for that let's write test inputs   is equal to test data final and then close dot 
values now if if you remember the way I actually   did in the I did it for the training trading 
sorry training of training the model I’ll have   to reshape into two dimensions and in this case 
I’m actually using np dot reshape or actually   we can we can do it like this test input start 
reshape minus one comma one if you're confused   about all these things just watch my last video 
actually I did all these things in my previous   video as well like you can see over here so I’m 
just doing the same things here for the test   data as well now model inputs will be imagine 
what right we'll have to squeeze the data right   between zero and one so scalar dot transform what 
is scalar by the way scalar is this one which is   which will be required to squeeze the data between 
zero and one as we did for the training purpose   right so it will be between zero and one right 
so oh sorry it will we have already provided   this thing which is zero and one I’ll have to 
provide test inputs here now if we see what is   the models model inputs you can see all the 
data is being squeezed to squeeze between 0   and 1 right and if you just write dot shape 
it should be something something comma 1   which is 855 comma 1 right perfectly exactly as we 
want now let's make an x test the way we made the   x train right for x in range time interval to 
train comma len of model inputs this time x   test com dot append and then we need model inputs 
again it's exactly the same thing which is x minus   time interval time intervals to train com and then 
from there to x comma zero so again like we have   we're actually making a list of multiple arrays 
with the length of 24 right the same way we did   for extra x strain now we will convert x test in 
to an array because it's a list right now and then   what next just guess we'll have to reshape into 
three dimensions because this is how we will be   using the lst model so all everything is actually 
repetitive x test and then we need to provide   x test com dot shape zero comma x test dot shape 
one comma one and that's it so now we have x test   if I just write dot shape by the way guys shape is 
one of the most important things to check in in a   deep learning model because this I would say the 
most common error that people used to make there   are different types of shapes that are required 
to make any particular model and we will have to   actually follow that thing so we have to use 
np dot reshape again and again in this types of   model so you can see that it's a three-dimensional 
model right now a three dimensional np array numpy   array right now in front of us with 393 sorry 8 31 
entries in this direction and then 24 into another   dimension we have the third dimension which is 
just one now let's predict the price prediction   prices is equal to model predict and the next test 
as simple as that now if let me just do one thing   if I if I run this cell you can see that the 
prices that are predicted are also between zero   and one we don't want prices to be between zero 
and one now because we I want the actual price   that will be compared with the actual bitcoin 
prices right so I’ll have to use inverse fit   transform scalar dot inverse transform and that's 
just the prediction prices right if I run this   and then after that if I run this one you can see 
that all the prediction are in front of you it's   float format so it will be easy there won't be any 
issue to plot these prices perfect so we have our   predict predicted prices as well now two things 
are remaining for in this video now I’ll plot the   graph now and then second thing is we will predict 
the next uh our price right so this is all about   the model now what is the next price that is going 
to happen after one hour or so right so we'll do   this thing two things after plotting the graph 
right so for plotting the graph I just hit plt dot   plot I’ve already imported matplotlib right so 
bitcoin prices let's make the label to be equal to bitcoin price prices plt.plot now I want 
prediction prices label equal to predicted   prices I just provided the name the title also 
just predicting bitcoin prices and then while   sorry x level is five minutes in time interval 
and y label is price now I just want plt dot   legend to show the final legends and then plt dot 
show perfect so we have got the final graph okay   interesting more or less it's the same but you can 
see that our orange line which is the predicted   price has predicted an upward movement much 
before the actual upward moment so you can see   it's on the left hand side so it has gone 
up before the actual bitcoin prices went up   and then similarly when it the the orange line 
went down before the bitcoin prices went down   and similarly again it went up before bitcoin 
prices went up and so on so yeah you can see   here also so it's amazing it's amazing actually 
it has a very good accuracy and if someone has   run this model at this moment of time 
you can see that the orange line is very below the actual blue line and at this time you 
should have sold bitcoin and actually went down   significantly I’m not 100 sure about the viability 
of this model but I can see that by just looking   at this graph you can see it's a it's a very good 
prediction in this one maybe in future I’ll keep   on working on this one and I’ll see what more 
I would say advancements can we make in this   particular model but actually I’m very happy with 
this one now now let's predict the next one hour   bitcoin price right actually it won't be predicted 
in the next one hour I’ll be predicting the next   price after this one so what will be the price 
on 24th 10 2021 and then one hour which is one   column zero zero column zero so the price at that 
moment of time so let's see what is the price so   for the last data I’m just providing last data 
is equal to so so now we just have one array   and this area will be the last 24 right so the 
last 24 is this length of the entire model just   plus one because the next one and then 
plus one minus will have to take out   the time interval which is time intervals to 
train just for train and then I will have to   from this level I’ll have to go to the last one 
which is the length of the model plus one perfect   comma zero I’ll have to convert it into np dot 
array now what next this guess guys I’m not going   forward just guess what what's the next step 
the next step is to reshape so last beta   is equal to np dot reshape last data comma now I i 
just need to get the this 24 so I just write a one   and then last data dot shape I’m interested in the 
zeroth one and that's it so let me just check it   if I just write last data dot shape it's 23 so 
I’ll have to convert it into three dimensional   right so it's 1 23 1 as simple as that prediction 
is equal to model dot predict and then last data   we can see if I just write prediction again it's 
oh you will have to we'll have to do the inverse   transform now so prediction is equal 
to scalar dot inverse transform   and then prediction if I write prediction you can 
see that the model is predicted that the next next   one hour price should be 60 614.023 now what's the 
reliability of this model this is your work now   this is how we can actually use the deep 
learning lsd model to do the prediction of   bitcoin prices now you'll get this code for free 
actually I share my google drive with all my   subscribers but before that if you like this video 
just just guys just give me one like on this video   and also the last one and also subscribe to this 
YouTube channel it really helps with the algorithm   also if you think that you you learn something 
today and if you want to tip me on the work that   I am actually doing for free to all my lovely 
subscribers and viewers you can actually tip   me by going to the link which is mentioned in 
the description box and euros or USD you just   need to select the number of coffees and I’ll just 
go outside to drink that coffee on your behalf   thank you so much for that if you're doing that 
in order to get a free access of my google drive   where I’ll be saving this code and there are 
actually many more codes saved over there such   as my trading board and my other amazing codes 
then what you need to do is just subscribe to   my YouTube channel and then click on this access 
to my google drive button just follow some steps   over there and then fill some information basic 
details over there and I’ll be using this email   address to give a free access of my google drive 
where I’ll be saving this code as well I hope   you like my video and the work that I’m doing 
for everyone I’ll see you in the next video

You May Also Like