We actually predict stock prices with machine learning investors make educated guesses by analyzing data will read the news study the company history industry trends there are lots of data points that go into making a prediction the prevailing theories that stock prices are totally random and unpredictable a blindfolded monkey throwing darts at newspaper's financial pages could select a portfolio that would do just as well as one carefully selected by expert but that raises the question why did top firms like Morgan family and Citigroup higher quantitative analyst to build predictive models we have this idea of a trading for being filled with adrenaline infuse men with highs running around yelling something is well Colin but these days are more likely to zero the machine-learning text first quietly sitting in front of computer screens in fact about seventy percent of all borders on Wall Street are now placed by software we're now living in the age of the algorithm hello world it's raj and today we're going to build a deep learning model to predict stock prices records of prices for traded commodities go back thousands of years merchant along popular silk route would keep records of trade good to try and predict price trends.
That they could benefit from them and finance the field of quantitative analysts about 25 years old and even now it's still not fully accepted understood or widely used just like Google+ it's a study of how certain variables correlate with stock price behavior one of the first attempt this was made in the seventies by two British statisticians inbox and Jenkins using mainframe computers the only historical data they had access to where prices and volume they call their model arima and at the time it was slow and expensive to run by the eighties things start to get interesting spreadsheets were invented to that firms could model company's financial performance and automated data collection became a reality and with improvements and computing power models could analyze data much faster it was a renaissance on Wall Street people were excited about the possibilities they started showing up at seminars and discussing their techniques you should see what's going on the bigger firms I mean I know all the information but all this quickly die down once people realize that what works is actually a very valuable secret right fuck all about consent the most successful concept underground in the past few years we've seen a lot of academic paper published using neural nets to predict stock prices with varying degrees of success but until recently the ability to build these model has been restricted to academics who spend their days writing very complex code now with libraries like tensorflow anyone can build powerful predictive model train on massive datasets.
Let's build our own model using care off with a tensorflow backend for our training data will be using the daily closing price of the SMP 500 from january 2002 August 2016. This is a series of data points indexed in time order or a time series our goal will be to predict the closing price for any given date after training we can load are they using a custom load data function essentially just read our CSV file into an array of values and normalizes them rather than being those values directly to our model normalizing them improve convergence will use this equation to normalize each value to reflect percentage changes from the starting point.
We'll divide each price by the initial price and subtract one when our model later makes prediction will be normalize the data using this formula to get a real world number out of it to build our model will first initialize it and sequential and it will be a linear stack of layers then we'll add our first layer which is an lstm layer to what is it let's back up for a bit recognize feet similar to this you don't have to think what you did I already know i sound from opinion it's easy to recall the word for word but could we sing them backwards no the reason for. This is because we learned these words in a sequence it's conditional memory we can access the word if we act of the word for it memory matters when we have sequences are thoughts have persistence but feed-forward neural Nets don't accept a thick sighs vector as input like an image.
We couldn't use it to say predict the next frame in a movie because that would require a sequence of images vectors as inputs not just one since the probability of a certain event happening would depend on what happened every frame before it we need a way to allow information to persist and that's why we'll use a recurrent neural net the current can accept sequences of vectors of inputs.
Recall that for feed-forward neural Nets the hidden layers wait are based only on the input data but in a recurrent that the hidden layer is a combination of the input data at the current time step and the hidden layer at a previous time step the hidden layer is constantly changing as it gets more inputs and the only way to reach these hidden States is with the correct sequence of inputs. This is how memory is incorporated in and we can model this process mathematically.
This hidden state at a given time that is a function of the input at that same time step modified by a weight matrix like the ones using feed-forward Mets added his State of the previous time step x its own hidden state to hidden state matrix otherwise known as a transition matrix and because it's feedback loop is occurring at every time step in the series each hidden state has traces of not only the previous hidden state but also of all of those that preceded it that's why we call it recurrent in a way we can think of it as copies of the same network each passing a message to the next.
That's the great thing about recurrent that they're able to connect previous data with the present task but we still have a problem take a look at this paragraph it starts off with I hope senpai will notice me and end with she is my friend he is my senpai let's say we wanted to train a model to predict this last word given all the other work we need to contact from the very beginning of the sequence to know that this word is probably senpai not something like buddy or make a regular recurrent net memories become more subtle as they ate into the past since the error signal from later time steps doesn't make it far enough back in time to influence the network at earlier time steps during backpropagation Joshua NGO called it the vanishing gradient problem in one of his most frequently cited papers piled learning long-term dependencies with gradient descent is difficult love the bluntness a popular solution to. This is a modification to recurring that's called long short term memory normally neurons are unit that apply an activation function like a sigmoid to a linear combination of their inputs in an LTM recurrent net we instead replacing neurons with water called memory cells each cell has been implicated in output gate and an internal state that feeds into itself across time steps with a constant weight of one this eliminates the vanishing gradient problem since any gradient that flows into the self recurring units during backdrop is preserved indefinitely since errors x 1 still have the same value HP is an activation function like signaling during the forward path to implicate learns when to let activation packed into the cell and the output learn to let activation pass out of it during the backward pass the output get learns when to let error flow into the cell and implicate one's going to let it flow out of himself through the rest of the network.
Despite everything else in a recurrent that staying the same doing this more powerful update equation for our hidden state results in our network being able to remember long-term dependencies.
For our lstm later we'll set our input dimension 21 and say we want 50 units in this layer setting return sequences to true means this layers output is always set into the next layer all its activations can be seen as a sequence of predictions the first layer has made from the input sequence will add twenty percent drop out to this layer then initialize our second layer as another lstm with 100 units and set return sequence to fall on it since its output is only fed to the next layer at the end of the sequence it doesn't help put a prediction for the sequence instead a prediction vector for the whole input sequence will use the linear dense layer to aggregate the data from the prediction dr. into one single value then we can compile our model using a popular loss function called mean squared error and use gradient descent our optimizer labeled rms prop will train our model with the function then we can test it to see what it predicts for the next 50 steps at several points in our graph and visualize it using that pot life it seems that for a lot of the price movement especially the big one there is quite a correlation between our models prediction and the actual data.
Time to make some money and place and he is what will our model be able to correctly predict the closing price one hundred percent of the time he'll to the no it's an analytical tool to help us make educated guesses about the direction of the market that is slightly better than random.
To break it down recurrent can model sequential data since at each time step the hidden state is affected by the input and the previous in state solution to the vanishing gradient problem for recurrent net is to use long short term memory cells to remember long-term dependencies and we can use lstm networks to make predictions for time series data easily you can carry off and tensorflow the winner of the coating talent in the last video is a shabbat you shall use transfer learning to create a classifier cats and dogs he chose the layer from a pre-training tentacle model and build his own custom convolutional net on top of it to make training much factor wizard of the week and the runner-up is GS shootin seeds i loved how he added a command-line interface for users to input their images the coding challenge for this video is to use three different inputs instead of just one to train your lstm networks to predict the price of google stock detailed in the readme poster gambling in the comments in all about the winner in a week please subscribe for more videos like this and for now i'm going to count my sack of layers.
Thanks for watching.
Paper Masters writes custom research papers on any business and MBA topic that you specify. You determine your business and MBA research paper topic and our writers write each project…Views: 2 706 By: Karen Sonnenberg
Alright guys, this month its 300+ essays all free to download on my website. My name is David Galloway and I am a professional essay writer. I've written over 10000+ essays in the…Views: 17 730 By: Honestd
Hi this is Laura Turner and today I'm going to talk to you about taking research notes. A research paper can be a pretty daunting task, but the most important thing for you to do…Views: 3 469 By: EHow
Hi. Let me share with you the concept map paragraph, and let me warn you that this is not write by numbers. Rather, I give you this paragraph because I want you to see how it functions…Views: 250 By: Tony Burman