By Devang Singh

**Introduction**

Machine learning has proved to improve efficiencies significantly, and there are many jobs which have been replaced by smarter and faster machines using artificial intelligence or machine learning. The stock markets are no exceptions to this. Today, there are several Machine Learning algorithms running in the live markets. These algorithms often provide greater returns than other alternate algorithms or sometimes even higher than experienced traders. In this article, I will talk about the concepts involved in a neural network and how it can be applied to predict stock prices in the live markets. Let us start by understanding what a neuron is.
**Neuron**

This is the neuron that you must be familiar with, well if you aren’t you should now be grateful that you can understand this because there are billions of neurons in your brain. There are three components to a neuron, the dendrites, the axon and the main body of the neuron. The dendrites are the receivers of the signal and the axon is the transmitter. Alone, a neuron is not of much use, but when it is connected to other neurons, it does several complicated computations and helps operate the most complicated machine on our planet, the human body.

A computer neuron is built in a similar manner, as shown in the diagram. There are inputs to the neuron marked with yellow circles, and the neuron emits an output signal after some computation. The input layer resembles the dendrites of the neuron and the output signal is the axon. Each input signal is assigned a weight, w_{i}. This weight is multiplied by the input value and the neuron stores the weighted sum of all the input variables. These weights are computed in the training phase of the neural network through concepts called gradient descent and back propagation, we will cover these topics in our subsequent blog posts on Neural Networks. An activation function is then applied to the weighted sum, which results in the output signal of the neuron. The input signals are generated by other neurons, i.e, the output of other neurons, and the network is built to make predictions/computations in this manner. This is the basic idea of a neural network. We will look at each of these concepts in more detail in this article.

**Working **of** Neural Networks**

We will look at an example to understand the working of neural networks. The input layer consists of the parameters that will help us arrive at an output value or make a prediction. Our brains essentially have five basic input parameters, which are our senses to touch, hear, see, smell and taste. The neurons in our brain create more complicated parameters such as emotions and feelings, from these basic input parameters. And our emotions and feelings, make us act or take decisions which is basically the output of the neural network of our brains. Therefore, there are two layers of computations in this case before making a decision. The first layer takes in the five senses as inputs and results in emotions and feelings, which are the inputs to the next layer of computations, where the output is a decision or an action. Hence, in this extremely simplistic model of the working of the human brain, we have one input layer, two hidden layers, and one output layer. Of course from our experiences, we all know that the brain is much more complicated than this, but essentially this is how the computations are done in our brain.
To understand the working of a neural network, let us consider a simple stock price prediction example, where the OHLCV (Open-High-Low-Close-Volume) values are the input parameters, there is one hidden layer and the output consists of the prediction of the stock price.

There are five input parameters as shown in the diagram, the hidden layer consists of 3 neurons and the resultant in the output layer is the prediction for the stock price. The 3 neurons in the hidden layer will have different weights for each of the five input parameters and might have different activation functions, which will activate the input parameters according to various combinations of the inputs. For example, the first neuron might be looking at the volume and the difference between the Close and the Open price and might be ignoring the High and Low prices. In this case, the weights for High and Low prices will be zero. Based on the weights that the model has trained itself to attain, an activation function will be applied to the weighted sum in the neuron, this will result in an output value for that particular neuron. Similarly, the other two neurons will result in an output value based on their individual activation functions and weights. Finally, the output value or the predicted value of the stock price will be the sum of the three output values of each neuron. This is how the neural network will work to predict stock prices.

**Conclusion**

Now that you understand the working of a neural network, you are ready to learn how the Artificial Neural Network will train itself to predict the movement of a stock price. In our next article on neural networks, we have delve deeper into the working of a neural network, by understanding how the weights of the neural network are learned through the process of training.
**Next Step**

Sign up for our latest course on 'Neural Networks in Trading' on Quantra. This course is authored by Dr. Ernest P. Chan and covers core concepts such as back and forward propagation to using LSTM models in Keras, everything is covered in a simplified manner with additional reading material provided for advanced learners. You can also leverage from hands-on coding experience and downloadable strategies to continue learning post course completion. Avail introductory discount, click here to know more.

*Disclaimer: All data and information provided in this article are for informational purposes only. QuantInsti® makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information in this article and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.*