SlideShare a Scribd company logo
1 of 19
WHAT IS THE LEAST SQUARES METHOD?
STEPS TO COMPUTE THE LINE OF BEST FIT
REGRESSION ANALYSIS USING PYTHON
LINE OF BEST FIT
www.edureka.co
THE LEAST-SQUARES REGRESSION METHOD WITH AN EXAMPLE
WHAT IS THE LEAST SQUARES REGRESSION
METHOD?
www.edureka.co
The least-squares regression method is a technique commonly used in Regression Analysis. It is a
mathematical method used to find the best fit line that represents the relationship between an
independent and dependent variable in such a way that the error is minimized.
What is the Least Squares Regression Method?
www.edureka.co
LINE OF BEST FIT
www.edureka.co
The Line of best fit line is drawn across a scatter plot of data points in order to represent a relationship
between those data points.
What is the Line Of Best Fit?
www.edureka.co
The least-squares method is one of the most effective ways used to draw the line of best fit. It is based on the idea that the
square of the errors obtained must be minimized to the most possible extent and hence the name least squares method.
STEPS TO COMPUTE THE LINE OF BEST FIT
www.edureka.co
To start constructing the line that best depicts the relationship between variables in the data, we
first need to get our basics right.
Steps to calculate the Line of Best Fit
www.edureka.co
𝑦 = π‘šπ‘₯ + 𝑐
Dependent
variable
Y-intercept
Independent variable
Slope of the line
A simple equation that represents a straight line along 2-Dimensional data, i.e. x-axis and y-axis.
The slope of a line characterizes the direction of a line. To find the slope, you divide the difference of
the y-coordinates of 2 points on a line by the difference of the x-coordinates of those same 2 points .
Step 1: Calculate the slope β€˜m’ of the line
www.edureka.co
π‘š =
𝑛 Οƒ π‘₯𝑦 βˆ’ 𝛴π‘₯ 𝛴𝑦
𝑛𝛴π‘₯2 βˆ’ 𝛴π‘₯ 2
m – slope of the line
n – total number of data points
x – Independent variable
y – Dependent variable
The y-intercept of a line is the value of y at the point where the line crosses the y axis.
Step 2: Compute the y-intercept
www.edureka.co
x
y
independent variable
dependentvariable
Y intercept (c)
Slope (m)
c = 𝑦 βˆ’ π‘šπ‘₯
Dependent variable
Y-intercept
Independent variable
Slope of the line
A simple equation that represents a straight line along 2-Dimensional data, i.e. x-axis and y-axis.
Step 3: Substitute the values in the final equation
www.edureka.co
𝑦 = π‘šπ‘₯ + 𝑐
Dependent
variable
Y-intercept
Independent variable
Slope of the line
THE LEAST-SQUARES REGRESSION
METHOD WITH AN EXAMPLE
www.edureka.co
Copyright Β© 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
www.edureka.co
Price of T-shirts
in dollars (x)
# of T-shirts sold
(y)
2 4
3 5
5 7
7 10
9 15
Step 1: Calculate the slope β€˜m’
Step 2: Compute the y-intercept value
Step 3: Substitute the values in the final equation
π‘š =
𝑛 Οƒ π‘₯π‘¦βˆ’ 𝛴π‘₯ 𝛴𝑦
𝑛𝛴π‘₯2βˆ’ 𝛴π‘₯ 2 = 1.518 approx
c = 𝑦 βˆ’ π‘šπ‘₯ = 0.305
y = 1.518 x + 0.305
Tom who is the owner of a retail shop, found the price of different T-shirts vs the number of T-shirts sold at
his shop over a period of one week.
www.edureka.co
Tom who is the owner of a retail shop, found the price of different T-shirts vs the number of T-shirts sold at
his shop over a period of one week.
Step 1: Calculate the slope β€˜m’
Step 2: Compute the y-intercept value
Step 3: Substitute the values in the final equation
π‘š =
𝑛 Οƒ π‘₯π‘¦βˆ’ 𝛴π‘₯ 𝛴𝑦
𝑛𝛴π‘₯2βˆ’ 𝛴π‘₯ 2 = 1.518 approx
c = 𝑦 βˆ’ π‘šπ‘₯ = 0.305
Consider x = $8,
y = 1.518 x 8 + 0.305 = 12.45 = 13 T-shirts
Price of
T-shirts
in dollars
(x)
# of T-
shirts
sold (y)
Y=mx+c error
2 4 3.3 -0.67
3 5 4.9 -0.14
5 7 7.9 0.89
7 10 10.9 0.93
9 15 13.9 -1.03
A few things to keep in mind before implementing the least squares regression method
Points To Remember
www.edureka.co
β€’ The data must be free of outliers.
β€’ Compute a line with the minimum possible squares of errors.
β€’ Least Squares Regression works perfectly even for non-linear data.
β€’ Technically, the difference between the actual value of β€˜y’ and the
predicted value of β€˜y’ is called the Residual
REGRESSION ANALYSIS USING PYTHON
www.edureka.co
Problem Statement: To apply Linear Regression using Least Squares Regression method and build a model that studies
the relationship between the head size and the brain weight of an individual..
Linear Regression Using Least Squares Regression Method In Python
www.edureka.co
Data Set Description: The data set contains the following variables:
β€’ Gender: Male or female represented as binary variables
β€’ Age: Age of an individual
β€’ Head size in cm^3: An individuals head size in cm^3
β€’ Brain weight in grams: The weight of an individual’s brain
measured in grams
www.edureka.co

More Related Content

What's hot

Simple & Multiple Regression Analysis
Simple & Multiple Regression AnalysisSimple & Multiple Regression Analysis
Simple & Multiple Regression AnalysisShailendra Tomar
Β 
Regression analysis.
Regression analysis.Regression analysis.
Regression analysis.sonia gupta
Β 
Least square method
Least square methodLeast square method
Least square methodPandidurai P
Β 
Linear regression
Linear regressionLinear regression
Linear regressionTech_MX
Β 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regressionRekhaChoudhary24
Β 
Regression Analysis
Regression AnalysisRegression Analysis
Regression AnalysisSalim Azad
Β 
Karl pearson's correlation
Karl pearson's correlationKarl pearson's correlation
Karl pearson's correlationfairoos1
Β 
Pearson's correlation
Pearson's  correlationPearson's  correlation
Pearson's correlationTRIPTI DUBEY
Β 
Curve fitting
Curve fittingCurve fitting
Curve fittingMayank Bhatt
Β 
Curve Fitting
Curve FittingCurve Fitting
Curve FittingSachin Kumar
Β 
Chapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares RegressionChapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares Regressionnszakir
Β 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear RegressionAndrew Ferlitsch
Β 
Regression analysis
Regression analysisRegression analysis
Regression analysisTeachers Mitraa
Β 
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha BaliRegression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha BaliAkanksha Bali
Β 
Regression
RegressionRegression
RegressionLavanyaK75
Β 
Regression
Regression Regression
Regression Ali Raza
Β 
Method of least square
Method of least squareMethod of least square
Method of least squareSomya Bagai
Β 

What's hot (20)

Simple & Multiple Regression Analysis
Simple & Multiple Regression AnalysisSimple & Multiple Regression Analysis
Simple & Multiple Regression Analysis
Β 
Regression analysis.
Regression analysis.Regression analysis.
Regression analysis.
Β 
Least square method
Least square methodLeast square method
Least square method
Β 
Linear regression
Linear regressionLinear regression
Linear regression
Β 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
Β 
Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
Β 
Karl pearson's correlation
Karl pearson's correlationKarl pearson's correlation
Karl pearson's correlation
Β 
Pearson's correlation
Pearson's  correlationPearson's  correlation
Pearson's correlation
Β 
Curve fitting
Curve fittingCurve fitting
Curve fitting
Β 
Curve Fitting
Curve FittingCurve Fitting
Curve Fitting
Β 
Multiple regression
Multiple regressionMultiple regression
Multiple regression
Β 
Chapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares RegressionChapter 2 part3-Least-Squares Regression
Chapter 2 part3-Least-Squares Regression
Β 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
Β 
Regression ppt
Regression pptRegression ppt
Regression ppt
Β 
Logistic regression
Logistic regressionLogistic regression
Logistic regression
Β 
Regression analysis
Regression analysisRegression analysis
Regression analysis
Β 
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha BaliRegression (Linear Regression and Logistic Regression) by Akanksha Bali
Regression (Linear Regression and Logistic Regression) by Akanksha Bali
Β 
Regression
RegressionRegression
Regression
Β 
Regression
Regression Regression
Regression
Β 
Method of least square
Method of least squareMethod of least square
Method of least square
Β 

Similar to Least Squares Regression Method | Edureka

Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning IntroductionKuppusamy P
Β 
Linear Regression
Linear RegressionLinear Regression
Linear RegressionSourajitMaity1
Β 
Curve Fitting detail explanation stat.pdf
Curve Fitting detail explanation stat.pdfCurve Fitting detail explanation stat.pdf
Curve Fitting detail explanation stat.pdfUVAS
Β 
Unit-III Correlation and Regression.pptx
Unit-III Correlation and Regression.pptxUnit-III Correlation and Regression.pptx
Unit-III Correlation and Regression.pptxAnusuya123
Β 
Bootcamp of new world to taken seriously
Bootcamp of new world to taken seriouslyBootcamp of new world to taken seriously
Bootcamp of new world to taken seriouslykhaled125087
Β 
Lect14 lines+circles
Lect14 lines+circlesLect14 lines+circles
Lect14 lines+circlesSiddharth Maloo
Β 
Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...ANIRBANMAJUMDAR18
Β 
99995320.ppt
99995320.ppt99995320.ppt
99995320.pptMohdSaqib79
Β 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regressionMaria Theresa
Β 
Curve_Fitting.pdf
Curve_Fitting.pdfCurve_Fitting.pdf
Curve_Fitting.pdfIrfan Khan
Β 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsAmol Gaikwad
Β 
Gradient Decent in Linear Regression.pptx
Gradient Decent in Linear Regression.pptxGradient Decent in Linear Regression.pptx
Gradient Decent in Linear Regression.pptxalphaomega55
Β 

Similar to Least Squares Regression Method | Edureka (20)

Regression
RegressionRegression
Regression
Β 
Regression
RegressionRegression
Regression
Β 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
Β 
Simple lin regress_inference
Simple lin regress_inferenceSimple lin regress_inference
Simple lin regress_inference
Β 
Linear Regression
Linear RegressionLinear Regression
Linear Regression
Β 
MSE.pptx
MSE.pptxMSE.pptx
MSE.pptx
Β 
Curve Fitting detail explanation stat.pdf
Curve Fitting detail explanation stat.pdfCurve Fitting detail explanation stat.pdf
Curve Fitting detail explanation stat.pdf
Β 
Regression
Regression  Regression
Regression
Β 
Unit-III Correlation and Regression.pptx
Unit-III Correlation and Regression.pptxUnit-III Correlation and Regression.pptx
Unit-III Correlation and Regression.pptx
Β 
Mathematical modeling
Mathematical modelingMathematical modeling
Mathematical modeling
Β 
Bootcamp of new world to taken seriously
Bootcamp of new world to taken seriouslyBootcamp of new world to taken seriously
Bootcamp of new world to taken seriously
Β 
Lect14 lines+circles
Lect14 lines+circlesLect14 lines+circles
Lect14 lines+circles
Β 
Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...Linear regression [Theory and Application (In physics point of view) using py...
Linear regression [Theory and Application (In physics point of view) using py...
Β 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
Β 
99995320.ppt
99995320.ppt99995320.ppt
99995320.ppt
Β 
Simple linear regression
Simple linear regressionSimple linear regression
Simple linear regression
Β 
Curve_Fitting.pdf
Curve_Fitting.pdfCurve_Fitting.pdf
Curve_Fitting.pdf
Β 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
Β 
Gradient Decent in Linear Regression.pptx
Gradient Decent in Linear Regression.pptxGradient Decent in Linear Regression.pptx
Gradient Decent in Linear Regression.pptx
Β 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
Β 

More from Edureka!

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaEdureka!
Β 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaEdureka!
Β 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaEdureka!
Β 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaEdureka!
Β 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaEdureka!
Β 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaEdureka!
Β 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaEdureka!
Β 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaEdureka!
Β 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaEdureka!
Β 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaEdureka!
Β 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | EdurekaEdureka!
Β 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEdureka!
Β 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEdureka!
Β 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaEdureka!
Β 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaEdureka!
Β 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaEdureka!
Β 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Edureka!
Β 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaEdureka!
Β 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaEdureka!
Β 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | EdurekaEdureka!
Β 

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Β 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Β 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Β 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Β 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Β 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Β 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Β 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Β 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Β 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Β 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Β 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Β 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Β 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Β 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Β 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Β 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Β 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Β 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Β 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Β 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
Β 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
Β 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
Β 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
Β 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
Β 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
Β 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
Β 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
Β 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
Β 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
Β 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
Β 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
Β 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
Β 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
Β 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
Β 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
Β 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
Β 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
Β 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
Β 

Recently uploaded (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
Β 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Β 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Β 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
Β 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Β 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
Β 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Β 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
Β 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
Β 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Β 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
Β 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Β 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Β 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
Β 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Β 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
Β 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
Β 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
Β 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
Β 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Β 

Least Squares Regression Method | Edureka

  • 1.
  • 2. WHAT IS THE LEAST SQUARES METHOD? STEPS TO COMPUTE THE LINE OF BEST FIT REGRESSION ANALYSIS USING PYTHON LINE OF BEST FIT www.edureka.co THE LEAST-SQUARES REGRESSION METHOD WITH AN EXAMPLE
  • 3. WHAT IS THE LEAST SQUARES REGRESSION METHOD? www.edureka.co
  • 4. The least-squares regression method is a technique commonly used in Regression Analysis. It is a mathematical method used to find the best fit line that represents the relationship between an independent and dependent variable in such a way that the error is minimized. What is the Least Squares Regression Method? www.edureka.co
  • 5. LINE OF BEST FIT www.edureka.co
  • 6. The Line of best fit line is drawn across a scatter plot of data points in order to represent a relationship between those data points. What is the Line Of Best Fit? www.edureka.co The least-squares method is one of the most effective ways used to draw the line of best fit. It is based on the idea that the square of the errors obtained must be minimized to the most possible extent and hence the name least squares method.
  • 7. STEPS TO COMPUTE THE LINE OF BEST FIT www.edureka.co
  • 8. To start constructing the line that best depicts the relationship between variables in the data, we first need to get our basics right. Steps to calculate the Line of Best Fit www.edureka.co 𝑦 = π‘šπ‘₯ + 𝑐 Dependent variable Y-intercept Independent variable Slope of the line A simple equation that represents a straight line along 2-Dimensional data, i.e. x-axis and y-axis.
  • 9. The slope of a line characterizes the direction of a line. To find the slope, you divide the difference of the y-coordinates of 2 points on a line by the difference of the x-coordinates of those same 2 points . Step 1: Calculate the slope β€˜m’ of the line www.edureka.co π‘š = 𝑛 Οƒ π‘₯𝑦 βˆ’ 𝛴π‘₯ 𝛴𝑦 𝑛𝛴π‘₯2 βˆ’ 𝛴π‘₯ 2 m – slope of the line n – total number of data points x – Independent variable y – Dependent variable
  • 10. The y-intercept of a line is the value of y at the point where the line crosses the y axis. Step 2: Compute the y-intercept www.edureka.co x y independent variable dependentvariable Y intercept (c) Slope (m) c = 𝑦 βˆ’ π‘šπ‘₯ Dependent variable Y-intercept Independent variable Slope of the line
  • 11. A simple equation that represents a straight line along 2-Dimensional data, i.e. x-axis and y-axis. Step 3: Substitute the values in the final equation www.edureka.co 𝑦 = π‘šπ‘₯ + 𝑐 Dependent variable Y-intercept Independent variable Slope of the line
  • 12. THE LEAST-SQUARES REGRESSION METHOD WITH AN EXAMPLE www.edureka.co
  • 13. Copyright Β© 2017, edureka and/or its affiliates. All rights reserved. www.edureka.co
  • 14. www.edureka.co Price of T-shirts in dollars (x) # of T-shirts sold (y) 2 4 3 5 5 7 7 10 9 15 Step 1: Calculate the slope β€˜m’ Step 2: Compute the y-intercept value Step 3: Substitute the values in the final equation π‘š = 𝑛 Οƒ π‘₯π‘¦βˆ’ 𝛴π‘₯ 𝛴𝑦 𝑛𝛴π‘₯2βˆ’ 𝛴π‘₯ 2 = 1.518 approx c = 𝑦 βˆ’ π‘šπ‘₯ = 0.305 y = 1.518 x + 0.305 Tom who is the owner of a retail shop, found the price of different T-shirts vs the number of T-shirts sold at his shop over a period of one week.
  • 15. www.edureka.co Tom who is the owner of a retail shop, found the price of different T-shirts vs the number of T-shirts sold at his shop over a period of one week. Step 1: Calculate the slope β€˜m’ Step 2: Compute the y-intercept value Step 3: Substitute the values in the final equation π‘š = 𝑛 Οƒ π‘₯π‘¦βˆ’ 𝛴π‘₯ 𝛴𝑦 𝑛𝛴π‘₯2βˆ’ 𝛴π‘₯ 2 = 1.518 approx c = 𝑦 βˆ’ π‘šπ‘₯ = 0.305 Consider x = $8, y = 1.518 x 8 + 0.305 = 12.45 = 13 T-shirts Price of T-shirts in dollars (x) # of T- shirts sold (y) Y=mx+c error 2 4 3.3 -0.67 3 5 4.9 -0.14 5 7 7.9 0.89 7 10 10.9 0.93 9 15 13.9 -1.03
  • 16. A few things to keep in mind before implementing the least squares regression method Points To Remember www.edureka.co β€’ The data must be free of outliers. β€’ Compute a line with the minimum possible squares of errors. β€’ Least Squares Regression works perfectly even for non-linear data. β€’ Technically, the difference between the actual value of β€˜y’ and the predicted value of β€˜y’ is called the Residual
  • 17. REGRESSION ANALYSIS USING PYTHON www.edureka.co
  • 18. Problem Statement: To apply Linear Regression using Least Squares Regression method and build a model that studies the relationship between the head size and the brain weight of an individual.. Linear Regression Using Least Squares Regression Method In Python www.edureka.co Data Set Description: The data set contains the following variables: β€’ Gender: Male or female represented as binary variables β€’ Age: Age of an individual β€’ Head size in cm^3: An individuals head size in cm^3 β€’ Brain weight in grams: The weight of an individual’s brain measured in grams