GradientDescentExample | Example demonstrating how gradient descent | Machine Learning library
kandi X-RAY | GradientDescentExample Summary
kandi X-RAY | GradientDescentExample Summary
This code demonstrates how a gradient descent search may be used to solve the linear regression problem of fitting a line to a set of points. In this problem, we wish to model a set of points using a line. The line model is defined by two parameters - the line's slope m, and y-intercept b. Gradient descent attemps to find the best values for these parameters, subject to an error function. The code contains a main function called run. This function defines a set of parameters used in the gradient descent algorithm including an initial guess of the line slope and y-intercept, the learning rate to use, and the number of iterations to run gradient descent for. Using these parameters a gradient descent search is executed on a sample data set of 100 ponts. Here is a visualization of the search running for 200 iterations using an initial guess of m = 0, b = 0, and a learning rate of 0.000005.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Compute the gradient of the gradient .
- Run gradient descent .
- Compute the error .
- Gradient descent runner .
GradientDescentExample Key Features
GradientDescentExample Examples and Code Snippets
Community Discussions
Trending Discussions on GradientDescentExample
QUESTION
I'm following Andrew Ng Coursera course on Machine Learning and I tried to implement the Gradient Descent Algorithm in Python. I'm having trouble with the y-intercept parameter because it doesn't look like to go to the best value. Here's my code:
...ANSWER
Answered 2018-Feb-15 at 13:10The complete code for my Gradient Descent implementation could be found on my Github repository: Gradient Descent for Linear Regression
Thinking about what @relay said that the Gradient Descent algorithm does not guarantee to find the global minima I tried to come up with an helper function to limit guesses for the parameter a
in a certain search range, as follows:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install GradientDescentExample
You can use GradientDescentExample like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page