We will be taking data of flower petals' length in inches, width in inches, and color. With that information, and using our Neural Network, we will be able to classify the daunted ~mystery flower~ .
The NN will output a number between 0 and 1. The closer it is to 1, the more confident it is that the color will be red. The closer the number is to 0, the more confident it is that the color will be blue.
Okay! Now, let's dive into how the Neural Network algorithm works.
A neural network operates much like a person's brain. Similar to how people respond to external stimuli and weigh their options in order to make a decision, the Neural Network takes in inputs and multiplies them by "weights" and adds a bias.
Consider an example: Your friend is considering going to the movie theater on a given day. In real life there are a great many number of variables to consider, but for this example there is only the genre and the time.
Your friend loves science fiction and prefers to go to the movies at 6pm. However, your friend would rather see a science fiction movie at 9pm than a romantic comedy at 6pm.
Therefore, your friend must value the genre more than the time...this makes intuitive sense that some variables weigh more heavily when making a decision.
The beauty of the NN algorithm is that it mimics human thinking by taking those inputs and multiplying them by a fraction, the higher fraction being the one with more "weight."
The equation is as follows: z = w1*x + w2*y + b
In order to standardize the output to scale, z goes into an activation function. The sigmoid function 1/(1+e^-x) will squish the output to a value between 0 and 1.
The result of the sigmoid function is the prediction. But what do we do when the prediction is wrong? The squared error function! Otherwise known as cost = (pred-target)^2
If we want to get improve the prediction to get the cost (error) as close to zero as possible, we will need to take the derivative repeatedly. If we take the derivative, multiply it by our learning rate (.1) and subtract that from the original inputs in a loop, the slope will eventually hit zero!
Remember: our data involves the classification of flowers, so the NN will output a number closer to 1 the more confident it is that the mystery flower is red, and a number closer to 0 the more confident it is that the flower is blue.
Now we should take a look at our data.
Don't just glance at it. Absorb it and see if you can find the pattern yourself.
Now check out the mystery flower. Any guess on what color this flower might be?