0% found this document useful (0 votes)
17 views29 pages

18-Linear Regression

Linear Regression is a popular supervised machine learning algorithm used for predicting continuous variables by establishing a linear relationship between dependent and independent variables. There are two types: Simple Linear Regression, which uses one independent variable, and Multiple Linear Regression, which uses multiple independent variables. The goal is to find the best fit line that minimizes the error between predicted and actual values, utilizing a cost function to optimize regression coefficients.

Uploaded by

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

18-Linear Regression

Linear Regression is a popular supervised machine learning algorithm used for predicting continuous variables by establishing a linear relationship between dependent and independent variables. There are two types: Simple Linear Regression, which uses one independent variable, and Multiple Linear Regression, which uses multiple independent variables. The goal is to find the best fit line that minimizes the error between predicted and actual values, utilizing a cost function to optimize regression coefficients.

Uploaded by

dawasthi952
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Kareena Khatkar

Linear Regression in Machine Learning


▪ Linear Regression is one of the easiest and most popular supervised machine learning
algorithm.
▪ Linear regression makes predictions for continuous/real or numeric variables such as sales,
salary, age, product price, etc.
▪ It tries to find out the best linear relationship that describes the data you have.
▪ The value of the dependent variable of a linear regression model is a continuous value i.e.
real numbers.
▪ It is a statistical method that is used for predictive analysis.
▪ It assumes that there exists a linear relationship between a dependent variable and
independent variable(s).
▪ Linear regression algorithm shows a linear relationship between a dependent (y) and one
or more independent (y) variables, hence called as linear regression. Since linear
regression shows the linear relationship, which means it finds how the value of the
dependent variable is changing according to the value of the independent variable.
The sloped straight line representing the linear relationship that fits the given data best is called as a
regression line.
It is also called as best fit line.
Types of Linear Regression-
Based on the number of independent variables, there are two types of linear regression-
•Simple Linear Regression:
If a single independent variable is used to predict the value of a numerical dependent
variable, then such a Linear Regression algorithm is called Simple Linear Regression.

•Multiple Linear regression:


If more than one independent variable is used to predict the value of a numerical
dependent variable, then such a Linear Regression algorithm is called Multiple Linear
Regression.
1. Simple Linear Regression-

In simple linear regression, the dependent


variable depends only on a single
independent variable.

For simple linear regression, the form of the


model is-
Y = β0 + β1X

Here,
•Y is a dependent variable.
•X is an independent variable.
•β0 and β1 are the regression coefficients.
•β0 is the intercept or the bias that fixes the
offset to a line.
•β1 is the slope or weight that specifies the
factor by which X has an impact on Y.
2. Multiple Linear Regression-
In multiple linear regression, the dependent
variable depends on more than one independent
variables.
For multiple linear regression, the form of the
model is-
Y = β0 + β1X1 + β2X2 + β3X3 + …… + βnXn

Here,
•Y is a dependent variable.
•X1, X2, …., Xn are independent variables.
•β0, β1,…, βn are the regression coefficients.
•βj (1<=j<=n) is the slope or weight that specifies
the factor by which Xj has an impact on Y.
Linear Regression Line
A linear line showing the relationship between the dependent and independent variables is called
a regression line. A regression line can show two types of relationship:

❑ Positive Linear Relationship:


If the dependent variable increases on the Y-axis and
independent variable increases on X-axis, then such a
relationship is termed as a Positive linear relationship.

•Negative Linear Relationship:


If the dependent variable decreases on the Y-axis and
independent variable increases on the X-axis, then such a
relationship is called a negative linear relationship.
Finding the best fit line:
When working with linear regression, our main goal is to find the best fit line that means the error between
predicted values and actual values should be minimized. The best fit line will have the least error.
The different values for weights or the coefficient of lines (a0, a1) gives a different line of regression, so we
need to calculate the best values for a0 and a1 to find the best fit line, so to calculate this we use cost function.
Cost function-
•The different values for weights or coefficient of lines (a0, a1) gives the different line of regression, and the
cost function is used to estimate the values of the coefficient for the best fit line.
•Cost function optimizes the regression coefficients or weights. It measures how a linear regression model is
performing.
•We can use the cost function to find the accuracy of the mapping function, which maps the input variable to
the output variable. This mapping function is also known as Hypothesis function.
Residual = actual y value − predicted y value

You might also like