0% found this document useful (0 votes)
36 views23 pages

Machine Learning and Deep Learning Course

Linear regression is a machine learning algorithm that finds the linear relationship between a dependent (y) and independent (x) variable. It fits a straight line that minimizes the distance between the observed data points and the fitted line. The cost function, usually mean squared error (MSE), measures how close the fitted line is to the actual data, and gradient descent is used to update the coefficients and minimize the cost function to find the best fit line. R-squared determines how well the regression line represents the data distribution, with a value closer to 1 indicating a better fit.

Uploaded by

Kizifi
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)
36 views23 pages

Machine Learning and Deep Learning Course

Linear regression is a machine learning algorithm that finds the linear relationship between a dependent (y) and independent (x) variable. It fits a straight line that minimizes the distance between the observed data points and the fitted line. The cost function, usually mean squared error (MSE), measures how close the fitted line is to the actual data, and gradient descent is used to update the coefficients and minimize the cost function to find the best fit line. R-squared determines how well the regression line represents the data distribution, with a value closer to 1 indicating a better fit.

Uploaded by

Kizifi
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
You are on page 1/ 23

Machine Learning and Deep

Learning Course
Linear Regression in Machine Learning

• Linear regression is one of the easiest and most popular Machine


Learning algorithms.
• It is a statistical method that is used for predictive analysis.
• Linear regression makes predictions for continuous/real or numeric
variables such as sales, salary, age, product price, etc.
Linear Regression in Machine Learning

• 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
Linear Regression
• the linear regression model provides a sloped straight line
representing the relationship between the variables. Consider the
below image:
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.
Linear Regression Line

• 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
• 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. should be minimized.
• The best fit line will have the least error.
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:

For the above linear equation, MSE can be calculated as:

Where,
N=Total number of observation
Yi = Actual value
(1xi+a0)= Predicted value.
• 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.

• 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.
• It is done by a random selection of values of coefficient and then iteratively update the values
to reach the minimum cost function.
Linear model is a approximation of linear model used to describe
relationship between two or more variables

Predicting
continuous values
by using other
variables
In simple linear regression they are two key : X, Y.
The Y : the dependent values should be continuous values and can not be discrete.
The X : the independent variable can be measured as categorical or continuous
measurement scale
The coefficient “theta 0“Q0= interest, ”theta 1” Q1= gradient fitting line , the parameters for the line
and need be to adjust.
Must minimize the MSE based on finding the best parameters for
Q0,Q1.
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:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy