0% found this document useful (0 votes)
6 views4 pages

LR

Linear regression models the relationship between a dependent variable and one or more independent variables by finding the line of best fit that minimizes total error. The process involves calculating the slope (m) and intercept (c) using gradient descent, which iteratively updates these values based on the loss function until an optimal fit is achieved. The final values of m and c allow for predictions of the dependent variable Y based on the independent variable X.

Uploaded by

raghunathreddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views4 pages

LR

Linear regression models the relationship between a dependent variable and one or more independent variables by finding the line of best fit that minimizes total error. The process involves calculating the slope (m) and intercept (c) using gradient descent, which iteratively updates these values based on the loss function until an optimal fit is achieved. The final values of m and c allow for predictions of the dependent variable Y based on the independent variable X.

Uploaded by

raghunathreddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

• Linear regression is an approach of modeling the relationship between a dependent variable and

one or more independent variables.


• It finds the line of best fit through your data by searching for the value of the regression
coefficient(s) that minimizes the total error of the model.
• Let X be the independent variable and Y be the dependent variable. Linear relationship between
these two variables is defined as follows:

Our goal is to find (m, c), where c is Intercept (where the line crosses y-axis), m is Slope of the line
We will use the Mean Squared Error function to calculate the loss
Linear Regression Using Gradient
Descent
Algorithm
Input: Training data (X, Y) L learning rate
Ouput: m, c

1. Initially assign m=0, c=0 and L be the learning rate.


2. Calculate the partial derivative of the loss function with respect to m, and plug in the current values of x, y, m and c in it to obtain the derivative value D. D is the value of the partial derivative with respect ₘ to m.

Similarly, Dc is the partial derivative with respect to c,

3. Update the current value of m and c using the following equation

4. Repeat steps 2 and 3 until our loss function is a very small value or ideally 0 (which means 0 error or 100% accuracy).
5. The final value of m and c will be the optimum values for the best-fitted line and we can predict the value of Y for any given X.

You might also like