Linear Regression
Linear Regression
COURSE INSTRUCTOR:
Dr.R.UMamaheswari
Assoc.prof & HoD ECM
Linear Regression
Linear regression can be further divided into two types of the algorithm:
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.
For Linear Regression, we use the Mean Squared Error (MSE) cost
function, which is the average of squared error occurred between the
predicted values and actual values. It can be written as:
Residuals: The distance between the actual value and predicted values is
called residual. If the observed points are far from the regression line, then the
residual will be high, and so cost function will high. If the scatter points are
close to the regression line, then the residual will be small and hence the cost
function
Department of Electronics and Computer Engineering Slide No. 8
Topic: Linear Regression Course: Machine Learning
Gradient Descent:
Gradient descent is used to minimize the MSE by calculating the gradient of the
cost function.
A regression model uses gradient descent to update the coefficients of the line
by reducing the cost function.
Model Performance:
The Goodness of fit determines how the line of regression fits the set of
observations. The process of finding the best model out of various models is
called optimization. It can be achieved by below method
R-squared method:
R-squared is a statistical method that determines the goodness of fit.
It measures the strength of the relationship between the dependent and
independent variables on a scale of 0-100%.
The high value of R-square determines the less difference between the predicted
values and actual values and hence represents a good model.
It is also called a coefficient of determination, or coefficient of multiple
determination for multiple regression.
It can be calculated from the below formula
Homoscedasticity Assumption:
Homoscedasticity is a situation when the error term is the same for all the
values of independent variables. With homoscedasticity, there should be no
clear pattern distribution of data in the scatter plot.
Normal distribution of error terms:
Linear regression assumes that the error term should follow the normal
distribution pattern. If error terms are not normally distributed, then
confidence intervals will become either too wide or too narrow, which may
cause difficulties in finding coefficients.
It can be checked using the q-q plot. If the plot shows a straight line without
any deviation, which means the error is normally distributed.
No autocorrelations:
The linear regression model assumes no autocorrelation in error terms. If there
will be any correlation in the error term, then it will drastically reduce the accuracy
of the model. Autocorrelation usually occurs if there is a dependency between
residual errors.
Thank You