Learn about gradient descent linear regression, we have the largest and most updated gradient descent linear regression information on alibabacloud.com
a sample), in addition, we can also use gradient descent method to obtain our parameters, gradient descent method of interpretation will be mentioned in the following blog, here we use an example to illustrate:The title is: 50 Data sample points, of which X is the age of the 50 children, ages 2 to 8 years old, the age
The theoretical content of logistic regression it has been described in the previous article that Newton iterations can be used to solve parameters and that this method seems
Too complex, today we introduce another method called gradient descent . Of course, the minimum value is the gradient drop, and the maximum value
' * Yhold On % Plot (X, 0.0639 * X + 0.7502 )Plot (x (:, 2), 0.0639 * X (:, 2) + 0.7502) % corrected code
Use the gradient descend process to solve the problem:
% Exercise 2 Linear Regression % Data Is Roughly based On 2000 CDC growth figures % For Boys % X refers To A boy ' S age % Y Is A boy ' S height in meters % Clear All ; Close All ; Clcx =
series, which is not mentioned here. See also: http://www.cnblogs.com/tbcaaa8/p/4486297.html3. Generalized linear modelThe generalized linear model is based on the following three-point hypothesis:Suppose that a y (i) |x (i) is independent of each other and satisfies the distribution of the same exponential distribution familyhypothesis two E (T (Y (i)) |x (i)) is the parameter of the distribution that Y (
Objective: This article is mainly to practice multivariable linear regression problem (in fact, this article also on 3 variables), reference page: http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?course= Deeplearningdoc=exercises/ex3/ex3.html. In fact, in the previous blog Deep learning: Two (linear regression
), 1), x];w=inv (x ' *x) *x ' *yholdon%plot (x,0.0639*x+0.7502 ) Plot (x (:,2), 0.0639*x (:, 2) +0.7502)% corrected codeUsing gradient descend Process solution: % Exercise 2Linear Regression% Data is roughly based on 2000CDC Growth Figures% forBoysPercent X refers to a boy's age% y is a boy's height in meters%clear all; close all; Clcx= Load (' Ex2x.dat '); y = Load (' Ex2y.dat '); M= Length (y); %Number of
is similar to that of linear regression and logistic regression:
Calculation cost function: J (θ)
Adjust ParametersθTo make the cost function value as small as possible
The next task is to calculate the output of the sample in the current model for each sample, find the cost function, and then update the weight parameter based on the output.Model output: For
Download Training Set data first Ex2data.zip , there are 50 training samples, X is 50 children's age, age is 2 to 8 years old, Y is the height of the corresponding child, age and height can be expressed as a decimal form, the current demand is based on the sample data of these 50 children to predict the height of children 3.5 and 7 years old. below, we first draw the 50 children sample data scatter chart, using the tool for MATLAB. First step: Load Data x = Load (' Ex2x.dat '); y = Load ('
Tags: probability gradient drop RAM log directory UNC measure between playFinishing the Machine Learnig course from Andrew Ng Week1Directory:
What is machine learning
Supervised learning
Non-supervised learning
Unary linear regression
Model representation
Loss function
Gradient
optimal solution, the path down the mountain is composed of several. Only one path is shown in the figure.Is the gradient descent process, which, in the middle, we continuously modify the value of the theta until it converges. ": =" is an assignment, "=" is equivalent to "= =" in the C language, is a comparison. Learning rate is the speed of learning, and in that case down the hill, it's the size of the
Machine Learning: Linear Regression With Multiple Variables, linearregressionMachine Learning: Linear Regression With Multiple Variables
Next, the example of the previous prediction of the house price leads to a multi-variable linear reg
% ====================================================== ===================end Note:caculating the cost function was useful for plotting the figure, but it's not used in gradient descent because the de Rivative'll make the square caculation become mutiply caculation.Gradient descent (for one Variable)By the formula for gradi
regression.
The root number can also be selected based on the actual situation.Regular Equation
In addition to Iteration Methods, linear algebra can be used to directly calculate $ \ matrix {\ Theta} $.
For example, four groups of property price forecasts:
Least Squares
$ \ Theta = (\ matrix {x} ^ t \ matrix {x}) ^ {-1} \ matrix {x} ^ t \ matrix {y} $Gradient
sample in the training set. Therefore, it is called batch gradient descent (batch gradient descent ), when the number of samples is small, it is acceptable, but when the number of samples is very large, this update will make the algorithm very inefficient. You can consider the following update method:
In this way, ea
); theta = Theta-alpha (alpha_i) .*grad; end plot (0:49, Jtheta ( 1:50), char (Plotstyle (alpha_i)), ' LineWidth ', 2)% be sure to convert by Char function hold on if (1 = = Alpha (alpha_i))% The experiment found that Alpha was1 o'clock the effect is best, then the theta value after the iteration is the desired value theta_grad_descent = theta endendlegend (' 0.01 ', ' 0.03 ', ' 0.1 ', ' 0.3 ', ' 1 ', ' 1.3 '); Xlabel (' Number of iterations ') ylabel (' cost function ')% below is the pred
what is linear regression. The so-called linear regression (taking a single variable as an example) is to give you a bunch of points, and you need to find a straight line from this pile of points. Figure below
This screenshot is from Andrew Ng's What you can do when you find this line. Let's say we find A and b that re
This article will cover:
(1) Another Linear Regression Method: normal equation; (2) Advantages and Disadvantages of gradient descent and normal equation;
Previously we used the Gradient Descent Method for
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.