Wednesday, December 21, 2016
Gradient Descent Linear Regression Curve Fitting Simple Implementation in C++
December 21, 2016
c++ code
,
curve fitting
,
error minimization from curve to points
,
gradient descent
,
linear regression
,
machine learning
,
simple implementation cpp
Explanation:
This code made following Andrew NG's machine learning course on coursera. The program has no input for simplicity, all input data are hard coded. Beware the tolerance version of code can not handle random data, please use the one with fixed iteration count.TODO
Visualization:
Applying hypothesis in a random sample:
This is another example taking some random numbers and try to fit a line through them to minimize error.Code Random Sample with Tolerance:
Code Random Sample with Fixed Iterations:
Code Curve Fitting through Prime Numbers:
Prime numbers on a graph:
This is before applying any hypotheses. Just putting the prime numbers in the graph against their index or order.Applying hypotheses calculated by program:
A line a can never go though all the prime number points. So the task is to minimize the distance of all the points to curve is minimized. In other words the task is to optimize in such a way that the error value is minimum.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment