Linear Regression using Gradient Descent

Gradient is the generalization of the usual concept of derivative to a function of several variables. Err... Simply put, the variation of a parameter in  an environment  such that measuring any two points inform us about the direction of increasing density.

Descent is well.. descent ..on the gradient. That is to reach the highest (or lowest?) density in gradual steps.
The task of Gradient Descent algorithm is to find t0 and t1 such that y = t0 +  (t1 * x)
For more, go here Gradient Descent

Input Process
Gradient Descent 
Observe that :
           if x is input ,
              then
                  output   y= 3x
This is learnt by the algorithm through the input training data.  
And the fitting parameter  t1 also gradually converges to ~3

Regression on new input 

The machine learns that the output needs to be 3 times that of input just by learning from data.
Well documented Code is on GitHub

Due to limited buffer space, all iterations with their respective parameters are logged into a data file.Here is the data file for the above set:

Everything done in Visual Studio 2010

0 comments:

Post a Comment