"Machine Learning Classic algorithm Source Analysis series"--Linear regression

Source: Internet
Author: User

One, single variable linear regression:

1. Data Set Visualization

2. Solving model parameters

For linear regression models, there are two ways to solve model parameters.

1) Gradient Descent method

Take the cost function into the expansion:

MATLAB Code implementation:

2) Normal equation

MATLAB Code implementation:

On the derivation of the normal equation:

3) Comparison of gradient descent method and normal equation

From the console output model parameters and regression lines, the results are very similar, the specific choice of what method to reference the following criteria.

Linear regression of multivariate variables

The multivariate linear regression solution is similar to the one-variable linear regression, and one of the notable problems is:

For more than one characteristic variable, we should remember to do feature scaling before calculating the model parameters, so that the characteristic values are roughly in the same range, which is advantageous to the gradient descent algorithm to solve the model parameters.

Describes one of the following methods:

MATLAB implementation:

In comparison, the normal equations omit the step of feature scaling when dealing with multivariable regression equations, simply follow the steps of a single variable and be more concise.

Three, the choice of learning rate

The efficiency of gradient descent is greatly influenced by the learning rate, which is too small, the convergence rate is very slow, and the number of iterations is increased; when too large, each iteration may not reduce the cost function, or even cross the local minimum value cannot converge.

Options that can be made by means of a test: such as 0.01,0.03,0.1,0.3,1,3,10 ...

PS: Source code interpretation for the Stanford University Machine Learning Program (2014 edition)-the industry Daniel Andrew Ng (Wu Enmin) as the keynote speaker.

PPS: This series of course notes "Brother Pure Handwriting":http://www.cnblogs.com/always-chang/p/5935787.html

Video URL:https://www.coursera.org/learn/machine-learning

Video download:http://pan.baidu.com/s/1dEJcXrj Password: bnks

Source Detailed analysis:http://pan.baidu.com/s/1bo8rIXL Password: hdn7

"Machine Learning Classic algorithm Source Analysis series"--Linear regression

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.