SlideShare a Scribd company logo
1 of 13
Download to read offline
Linear Regression
Dr. Varun Kumar
Dr. Varun Kumar Lecture 5 1 / 13
Outlines
1 Linear Regression:
2 Basic Rule for Linear Regression:
3 Parametric Estimation in Linear Regression
4 Linear Regression of Higher Order
5 Introduction to Quadratic or Polynomial Regression
6 References
Dr. Varun Kumar Lecture 5 2 / 13
Linear Regression:
Linear Regression:
Linear regression is an approach to model the relationship between a scalar
response (or dependent variable) and one or more explanatory variables (or
independent variables). The case of one explanatory variable is called
simple linear regression.
y = mx + c ⇒ y
Independent variable
= m x
Dependent variable
+ c
m → Gradient or slope and y → Intercept
or
y = a1x1 + a2x2 + ..... + akxk + b
Here, y → Independent variable
x1, x2, ...., xk → Dependent variable
Dr. Varun Kumar Lecture 5 3 / 13
Basic Rule for Linear Regression:
Table for Doing Bi-variate Linear Regression
y x ˆx − x ˆy − y
y1 x1 ˆx − x1 ˆy − y1
y2 x2 ˆx − x2 ˆy − y2
...
...
...
...
yk−1 xk−1 ˆx − xk−1 ˆy − yk−1
yk xk ˆx − xk ˆy − yk
ˆy = mean(y) ˆx = mean(x)
m =
k
i=1(ˆx − xi )(ˆy − yi )
k
i=1(ˆx − xi )2
Based on these observation, estimated straight line equation can be
y − ˆy = m(x − ˆx) or y = mx + c, where c = mˆx + ˆy
Dr. Varun Kumar Lecture 5 4 / 13
Continued–
Note:
1 There may exist infinite number of lines for different gradient and
intercept value.
2 Straight line is supposed to be best-fit in linear regression line that
gives the minimum least square error.
3 In linear regression, fitness of straight line can also be calculated as
R2 value. Lower the R2 greater be the fitness of straight line.
4 Above straight line may be one solution, but cannot say the true
estimate that gives minimum mean square error.
Calculation of R2
R2
=
(yp − ˆy)2
(yi − ˆy)2
where yp → Predicted value from st line.
yi → Value of ith sample of y vector
Dr. Varun Kumar Lecture 5 5 / 13
Parametric Estimation in Linear Regression
Mean Square Error:
MSE = 1
N (yp − yi )2
Parametric Estimation in Linear Regression
Let linear regression model is as follow
r = f (x) +
f (x) is unknown function, which requires to estimate properly.
G(x|θ) → Linear estimator, estimate the unknown function f (x).
∼ N(0, σ2)
p(r|x) ∼ N(G(x|θ), σ2)
Maximum likelihood is used to learn the parameters θ.
Dr. Varun Kumar Lecture 5 6 / 13
Continued–
The pairs (xt, rt) in the training set are drawn from an unknown joint
probability density p(x, r), which we can write as
p(x, r) = p(r|x)p(x)
Let χ = {xt, rt}N
t=1 → Training set.
Log-likelihood Function :
L(θ|χ) = log{p(r, x)} = log(p(r|x)) + log(p(x))
= log( N
t=1 p(rt|xt)) + log( N
t=1 p(xt))
Note: We can ignore the second term since it does not depend on our
estimator.
L(θ|χ) = log
N
t=1
1
√
2πσ
e
(rt −G(x|θ))2
2σ2
= −N log(
√
2πσ) −
1
2σ2
N
t=1
(rt
− G(x|θ))2
Dr. Varun Kumar Lecture 5 7 / 13
Continued–
Note:
In log-likelihood function L(θ|χ), first term is independent from dependent
parameter θ.
Maximizing this is equivalent to minimizing the error function,
E(θ|χ) =
−1
2σ2
N
t=1
(rt
− G(x|θ))2
In linear regression, we have a linear model
G(xt
|w1, w0) = w1xt
+ w0
There are two unknown w1 and w0. Hence, there require two equation.
N
t=1
rt
= Nw0 + w1
N
t=1
xt
(1)
Dr. Varun Kumar Lecture 5 8 / 13
Continued–
N
t=1
rt
xt
= w0
N
t=1
xt
+ w1
N
t=1
(xt
)2
(2)
which can be written in vector-matrix form as Aw = y where
A =
N N
t=1 xt
N
t=1 xt N
t=1(xt)2 W =
w0
w1
Hence, we can estimate the parameter w0 and w1 by estimator G(x|θ)
using training set χ = {xt, rt}
W = A−1
y
Dr. Varun Kumar Lecture 5 9 / 13
Linear Regression of Higher Order:
Example:
1 Let a mathematical input-output relation is such a way that
r = f (x) + b
where unknown function f (x) is estimated by a linear estimator
G(x|θ) = a1x1 + a2x2 + a3x3 + b
where, x = {x1, x2, x3} and θ = {a1, a2, a3, b} training data set
χ = {rt, xt
1, xt
2, xt
3}N
t=1, respectively .
Ans. Let us start with second question, where four unknown and total 5N
number of training data
N
t=1
rt
= bN + a1
N
t=1
xt
1 + a2
N
t=1
xt
2 + a3
N
t=1
xt
3 (3)
Dr. Varun Kumar Lecture 5 10 / 13
Continued–
N
t=1
rt
xt
1 = b
N
t=1
xt
1 + a1
N
t=1
(xt
1)2
+ a2
N
t=1
xt
1xt
2 + a3
N
t=1
xt
1xt
3 (4)
N
t=1
rt
xt
2 = b
N
t=1
xt
2 + a1
N
t=1
xt
2xt
1 + a2
N
t=1
(xt
2)2
+ a3
N
t=1
xt
2xt
3 (5)
N
t=1
rt
xt
3 = b
N
t=1
xt
3 + a1
N
t=1
xt
3xt
1 + a2
N
t=1
xt
3xt
2 + a3
N
t=1
(xt
3)2
(6)
From previous example, we can also express as
AW = y
where y = N
t=1 rt, N
t=1 rtxt
1, N
t=1 rtxt
2, N
t=1 rtxt
3
T
Dr. Varun Kumar Lecture 5 11 / 13
Quadratic or Polynomial Regression
Quadratic or Polynomial Regression :
For quadratic regression, our estimator can be modeled as
G(x|θ) = a2x2
+ a1x + a0
Here, θ = a2, a1, a0
For polynomial regression, our estimator can be modeled as
G(x|θ) = anxn
+ an−1xn−1
+ ..... + a0
Here, θ = an, an−1, ...., a0
Dr. Varun Kumar Lecture 5 12 / 13
References
E. Alpaydin, Introduction to machine learning. MIT press, 2020.
T. M. Mitchell, The discipline of machine learning. Carnegie Mellon University,
School of Computer Science, Machine Learning , 2006, vol. 9.
J. Grus, Data science from scratch: first principles with python. O’Reilly Media,
2019.
Dr. Varun Kumar Lecture 5 13 / 13

More Related Content

What's hot

Gauss y gauss jordan
Gauss y gauss jordanGauss y gauss jordan
Gauss y gauss jordanjonathann89
 
A Note on Hessen berg of Trapezoidal Fuzzy Number Matrices
A Note on Hessen berg of Trapezoidal Fuzzy Number MatricesA Note on Hessen berg of Trapezoidal Fuzzy Number Matrices
A Note on Hessen berg of Trapezoidal Fuzzy Number MatricesIOSRJM
 
Determinant
Determinant Determinant
Determinant GpmMaths
 
Indefinite Integral
Indefinite IntegralIndefinite Integral
Indefinite IntegralRich Elle
 
9.4 Cramer's Rule
9.4 Cramer's Rule9.4 Cramer's Rule
9.4 Cramer's Rulesmiller5
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature FormulaMaitree Patel
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsMeenakshisundaram N
 
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULANUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULAKHORASIYA DEVANSU
 
Gauss elimination method
Gauss elimination methodGauss elimination method
Gauss elimination methodgilandio
 
Gauss jordan and Guass elimination method
Gauss jordan and Guass elimination methodGauss jordan and Guass elimination method
Gauss jordan and Guass elimination methodMeet Nayak
 
9.2 Matrices
9.2 Matrices9.2 Matrices
9.2 Matricessmiller5
 
Iterativos Methods
Iterativos MethodsIterativos Methods
Iterativos MethodsJeannie
 
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsGauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsJanki Shah
 

What's hot (20)

Nmsa 170900713008
Nmsa 170900713008Nmsa 170900713008
Nmsa 170900713008
 
Cramer's Rule
Cramer's RuleCramer's Rule
Cramer's Rule
 
Gauss y gauss jordan
Gauss y gauss jordanGauss y gauss jordan
Gauss y gauss jordan
 
01.02 linear equations
01.02 linear equations01.02 linear equations
01.02 linear equations
 
Gauss jordan
Gauss jordanGauss jordan
Gauss jordan
 
A Note on Hessen berg of Trapezoidal Fuzzy Number Matrices
A Note on Hessen berg of Trapezoidal Fuzzy Number MatricesA Note on Hessen berg of Trapezoidal Fuzzy Number Matrices
A Note on Hessen berg of Trapezoidal Fuzzy Number Matrices
 
Determinant
Determinant Determinant
Determinant
 
Indefinite Integral
Indefinite IntegralIndefinite Integral
Indefinite Integral
 
9.4 Cramer's Rule
9.4 Cramer's Rule9.4 Cramer's Rule
9.4 Cramer's Rule
 
Gauss elimination
Gauss eliminationGauss elimination
Gauss elimination
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature Formula
 
Numerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential EquationsNumerical Solution of Ordinary Differential Equations
Numerical Solution of Ordinary Differential Equations
 
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULANUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
 
Gauss elimination method
Gauss elimination methodGauss elimination method
Gauss elimination method
 
Gauss jordan and Guass elimination method
Gauss jordan and Guass elimination methodGauss jordan and Guass elimination method
Gauss jordan and Guass elimination method
 
Nsm
Nsm Nsm
Nsm
 
Alin 2.2 2.4
Alin 2.2 2.4Alin 2.2 2.4
Alin 2.2 2.4
 
9.2 Matrices
9.2 Matrices9.2 Matrices
9.2 Matrices
 
Iterativos Methods
Iterativos MethodsIterativos Methods
Iterativos Methods
 
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical MethodsGauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
Gauss Elimination & Gauss Jordan Methods in Numerical & Statistical Methods
 

Similar to Linear Regression

Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...Dr.Summiya Parveen
 
Data Approximation in Mathematical Modelling Regression Analysis and curve fi...
Data Approximation in Mathematical Modelling Regression Analysis and curve fi...Data Approximation in Mathematical Modelling Regression Analysis and curve fi...
Data Approximation in Mathematical Modelling Regression Analysis and curve fi...Dr.Summiya Parveen
 
2 random variables notes 2p3
2 random variables notes 2p32 random variables notes 2p3
2 random variables notes 2p3MuhannadSaleh
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptxMdRokonMia1
 
線形回帰モデル
線形回帰モデル線形回帰モデル
線形回帰モデル貴之 八木
 
Cheatsheet supervised-learning
Cheatsheet supervised-learningCheatsheet supervised-learning
Cheatsheet supervised-learningSteve Nouri
 
OR Linear Programming
OR Linear ProgrammingOR Linear Programming
OR Linear Programmingchaitu87
 
Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3Fabian Pedregosa
 
Average value by integral method
Average value by integral methodAverage value by integral method
Average value by integral methodArun Umrao
 
Generalized Nonlinear Models in R
Generalized Nonlinear Models in RGeneralized Nonlinear Models in R
Generalized Nonlinear Models in Rhtstatistics
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical MethodsTeja Ande
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus AhsanIrshad8
 
simple linear regression - brief introduction
simple linear regression - brief introductionsimple linear regression - brief introduction
simple linear regression - brief introductionedinyoka
 

Similar to Linear Regression (20)

Metodo gauss_newton.pdf
Metodo gauss_newton.pdfMetodo gauss_newton.pdf
Metodo gauss_newton.pdf
 
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
 
Data Approximation in Mathematical Modelling Regression Analysis and curve fi...
Data Approximation in Mathematical Modelling Regression Analysis and curve fi...Data Approximation in Mathematical Modelling Regression Analysis and curve fi...
Data Approximation in Mathematical Modelling Regression Analysis and curve fi...
 
PCA on graph/network
PCA on graph/networkPCA on graph/network
PCA on graph/network
 
2 random variables notes 2p3
2 random variables notes 2p32 random variables notes 2p3
2 random variables notes 2p3
 
Regression Analysis.pptx
Regression Analysis.pptxRegression Analysis.pptx
Regression Analysis.pptx
 
lecture6.ppt
lecture6.pptlecture6.ppt
lecture6.ppt
 
線形回帰モデル
線形回帰モデル線形回帰モデル
線形回帰モデル
 
Cheatsheet supervised-learning
Cheatsheet supervised-learningCheatsheet supervised-learning
Cheatsheet supervised-learning
 
Econometrics 2017-graduate-3
Econometrics 2017-graduate-3Econometrics 2017-graduate-3
Econometrics 2017-graduate-3
 
OR Linear Programming
OR Linear ProgrammingOR Linear Programming
OR Linear Programming
 
Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3Random Matrix Theory and Machine Learning - Part 3
Random Matrix Theory and Machine Learning - Part 3
 
Average value by integral method
Average value by integral methodAverage value by integral method
Average value by integral method
 
Generalized Nonlinear Models in R
Generalized Nonlinear Models in RGeneralized Nonlinear Models in R
Generalized Nonlinear Models in R
 
Numerical Methods
Numerical MethodsNumerical Methods
Numerical Methods
 
Econometric lec3.ppt
Econometric  lec3.pptEconometric  lec3.ppt
Econometric lec3.ppt
 
ch02.pdf
ch02.pdfch02.pdf
ch02.pdf
 
The Fundamental theorem of calculus
The Fundamental theorem of calculus The Fundamental theorem of calculus
The Fundamental theorem of calculus
 
simple linear regression - brief introduction
simple linear regression - brief introductionsimple linear regression - brief introduction
simple linear regression - brief introduction
 
Section 7.4
Section 7.4Section 7.4
Section 7.4
 

More from VARUN KUMAR

Distributed rc Model
Distributed rc ModelDistributed rc Model
Distributed rc ModelVARUN KUMAR
 
Electrical Wire Model
Electrical Wire ModelElectrical Wire Model
Electrical Wire ModelVARUN KUMAR
 
Interconnect Parameter in Digital VLSI Design
Interconnect Parameter in Digital VLSI DesignInterconnect Parameter in Digital VLSI Design
Interconnect Parameter in Digital VLSI DesignVARUN KUMAR
 
Introduction to Digital VLSI Design
Introduction to Digital VLSI DesignIntroduction to Digital VLSI Design
Introduction to Digital VLSI DesignVARUN KUMAR
 
Challenges of Massive MIMO System
Challenges of Massive MIMO SystemChallenges of Massive MIMO System
Challenges of Massive MIMO SystemVARUN KUMAR
 
E-democracy or Digital Democracy
E-democracy or Digital DemocracyE-democracy or Digital Democracy
E-democracy or Digital DemocracyVARUN KUMAR
 
Ethics of Parasitic Computing
Ethics of Parasitic ComputingEthics of Parasitic Computing
Ethics of Parasitic ComputingVARUN KUMAR
 
Action Lines of Geneva Plan of Action
Action Lines of Geneva Plan of ActionAction Lines of Geneva Plan of Action
Action Lines of Geneva Plan of ActionVARUN KUMAR
 
Geneva Plan of Action
Geneva Plan of ActionGeneva Plan of Action
Geneva Plan of ActionVARUN KUMAR
 
Fair Use in the Electronic Age
Fair Use in the Electronic AgeFair Use in the Electronic Age
Fair Use in the Electronic AgeVARUN KUMAR
 
Software as a Property
Software as a PropertySoftware as a Property
Software as a PropertyVARUN KUMAR
 
Orthogonal Polynomial
Orthogonal PolynomialOrthogonal Polynomial
Orthogonal PolynomialVARUN KUMAR
 
Patent Protection
Patent ProtectionPatent Protection
Patent ProtectionVARUN KUMAR
 
Copyright Vs Patent and Trade Secrecy Law
Copyright Vs Patent and Trade Secrecy LawCopyright Vs Patent and Trade Secrecy Law
Copyright Vs Patent and Trade Secrecy LawVARUN KUMAR
 
Property Right and Software
Property Right and SoftwareProperty Right and Software
Property Right and SoftwareVARUN KUMAR
 
Investigating Data Trials
Investigating Data TrialsInvestigating Data Trials
Investigating Data TrialsVARUN KUMAR
 
Gaussian Numerical Integration
Gaussian Numerical IntegrationGaussian Numerical Integration
Gaussian Numerical IntegrationVARUN KUMAR
 
Censorship and Controversy
Censorship and ControversyCensorship and Controversy
Censorship and ControversyVARUN KUMAR
 
Romberg's Integration
Romberg's IntegrationRomberg's Integration
Romberg's IntegrationVARUN KUMAR
 
Introduction to Censorship
Introduction to Censorship Introduction to Censorship
Introduction to Censorship VARUN KUMAR
 

More from VARUN KUMAR (20)

Distributed rc Model
Distributed rc ModelDistributed rc Model
Distributed rc Model
 
Electrical Wire Model
Electrical Wire ModelElectrical Wire Model
Electrical Wire Model
 
Interconnect Parameter in Digital VLSI Design
Interconnect Parameter in Digital VLSI DesignInterconnect Parameter in Digital VLSI Design
Interconnect Parameter in Digital VLSI Design
 
Introduction to Digital VLSI Design
Introduction to Digital VLSI DesignIntroduction to Digital VLSI Design
Introduction to Digital VLSI Design
 
Challenges of Massive MIMO System
Challenges of Massive MIMO SystemChallenges of Massive MIMO System
Challenges of Massive MIMO System
 
E-democracy or Digital Democracy
E-democracy or Digital DemocracyE-democracy or Digital Democracy
E-democracy or Digital Democracy
 
Ethics of Parasitic Computing
Ethics of Parasitic ComputingEthics of Parasitic Computing
Ethics of Parasitic Computing
 
Action Lines of Geneva Plan of Action
Action Lines of Geneva Plan of ActionAction Lines of Geneva Plan of Action
Action Lines of Geneva Plan of Action
 
Geneva Plan of Action
Geneva Plan of ActionGeneva Plan of Action
Geneva Plan of Action
 
Fair Use in the Electronic Age
Fair Use in the Electronic AgeFair Use in the Electronic Age
Fair Use in the Electronic Age
 
Software as a Property
Software as a PropertySoftware as a Property
Software as a Property
 
Orthogonal Polynomial
Orthogonal PolynomialOrthogonal Polynomial
Orthogonal Polynomial
 
Patent Protection
Patent ProtectionPatent Protection
Patent Protection
 
Copyright Vs Patent and Trade Secrecy Law
Copyright Vs Patent and Trade Secrecy LawCopyright Vs Patent and Trade Secrecy Law
Copyright Vs Patent and Trade Secrecy Law
 
Property Right and Software
Property Right and SoftwareProperty Right and Software
Property Right and Software
 
Investigating Data Trials
Investigating Data TrialsInvestigating Data Trials
Investigating Data Trials
 
Gaussian Numerical Integration
Gaussian Numerical IntegrationGaussian Numerical Integration
Gaussian Numerical Integration
 
Censorship and Controversy
Censorship and ControversyCensorship and Controversy
Censorship and Controversy
 
Romberg's Integration
Romberg's IntegrationRomberg's Integration
Romberg's Integration
 
Introduction to Censorship
Introduction to Censorship Introduction to Censorship
Introduction to Censorship
 

Recently uploaded

Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesChandrakantDivate1
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxMuhammadAsimMuhammad6
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdfKamal Acharya
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdfKamal Acharya
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdfKamal Acharya
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Ramkumar k
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfsumitt6_25730773
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...ppkakm
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptxrouholahahmadi9876
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxNANDHAKUMARA10
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 

Recently uploaded (20)

Computer Graphics Introduction To Curves
Computer Graphics Introduction To CurvesComputer Graphics Introduction To Curves
Computer Graphics Introduction To Curves
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptxOrlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
Orlando’s Arnold Palmer Hospital Layout Strategy-1.pptx
 
Hospital management system project report.pdf
Hospital management system project report.pdfHospital management system project report.pdf
Hospital management system project report.pdf
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
Online electricity billing project report..pdf
Online electricity billing project report..pdfOnline electricity billing project report..pdf
Online electricity billing project report..pdf
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)Theory of Time 2024 (Universal Theory for Everything)
Theory of Time 2024 (Universal Theory for Everything)
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 
DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...Basic Electronics for diploma students as per technical education Kerala Syll...
Basic Electronics for diploma students as per technical education Kerala Syll...
 
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
457503602-5-Gas-Well-Testing-and-Analysis-pptx.pptx
 
Electromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptxElectromagnetic relays used for power system .pptx
Electromagnetic relays used for power system .pptx
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 

Linear Regression

  • 1. Linear Regression Dr. Varun Kumar Dr. Varun Kumar Lecture 5 1 / 13
  • 2. Outlines 1 Linear Regression: 2 Basic Rule for Linear Regression: 3 Parametric Estimation in Linear Regression 4 Linear Regression of Higher Order 5 Introduction to Quadratic or Polynomial Regression 6 References Dr. Varun Kumar Lecture 5 2 / 13
  • 3. Linear Regression: Linear Regression: Linear regression is an approach to model the relationship between a scalar response (or dependent variable) and one or more explanatory variables (or independent variables). The case of one explanatory variable is called simple linear regression. y = mx + c ⇒ y Independent variable = m x Dependent variable + c m → Gradient or slope and y → Intercept or y = a1x1 + a2x2 + ..... + akxk + b Here, y → Independent variable x1, x2, ...., xk → Dependent variable Dr. Varun Kumar Lecture 5 3 / 13
  • 4. Basic Rule for Linear Regression: Table for Doing Bi-variate Linear Regression y x ˆx − x ˆy − y y1 x1 ˆx − x1 ˆy − y1 y2 x2 ˆx − x2 ˆy − y2 ... ... ... ... yk−1 xk−1 ˆx − xk−1 ˆy − yk−1 yk xk ˆx − xk ˆy − yk ˆy = mean(y) ˆx = mean(x) m = k i=1(ˆx − xi )(ˆy − yi ) k i=1(ˆx − xi )2 Based on these observation, estimated straight line equation can be y − ˆy = m(x − ˆx) or y = mx + c, where c = mˆx + ˆy Dr. Varun Kumar Lecture 5 4 / 13
  • 5. Continued– Note: 1 There may exist infinite number of lines for different gradient and intercept value. 2 Straight line is supposed to be best-fit in linear regression line that gives the minimum least square error. 3 In linear regression, fitness of straight line can also be calculated as R2 value. Lower the R2 greater be the fitness of straight line. 4 Above straight line may be one solution, but cannot say the true estimate that gives minimum mean square error. Calculation of R2 R2 = (yp − ˆy)2 (yi − ˆy)2 where yp → Predicted value from st line. yi → Value of ith sample of y vector Dr. Varun Kumar Lecture 5 5 / 13
  • 6. Parametric Estimation in Linear Regression Mean Square Error: MSE = 1 N (yp − yi )2 Parametric Estimation in Linear Regression Let linear regression model is as follow r = f (x) + f (x) is unknown function, which requires to estimate properly. G(x|θ) → Linear estimator, estimate the unknown function f (x). ∼ N(0, σ2) p(r|x) ∼ N(G(x|θ), σ2) Maximum likelihood is used to learn the parameters θ. Dr. Varun Kumar Lecture 5 6 / 13
  • 7. Continued– The pairs (xt, rt) in the training set are drawn from an unknown joint probability density p(x, r), which we can write as p(x, r) = p(r|x)p(x) Let χ = {xt, rt}N t=1 → Training set. Log-likelihood Function : L(θ|χ) = log{p(r, x)} = log(p(r|x)) + log(p(x)) = log( N t=1 p(rt|xt)) + log( N t=1 p(xt)) Note: We can ignore the second term since it does not depend on our estimator. L(θ|χ) = log N t=1 1 √ 2πσ e (rt −G(x|θ))2 2σ2 = −N log( √ 2πσ) − 1 2σ2 N t=1 (rt − G(x|θ))2 Dr. Varun Kumar Lecture 5 7 / 13
  • 8. Continued– Note: In log-likelihood function L(θ|χ), first term is independent from dependent parameter θ. Maximizing this is equivalent to minimizing the error function, E(θ|χ) = −1 2σ2 N t=1 (rt − G(x|θ))2 In linear regression, we have a linear model G(xt |w1, w0) = w1xt + w0 There are two unknown w1 and w0. Hence, there require two equation. N t=1 rt = Nw0 + w1 N t=1 xt (1) Dr. Varun Kumar Lecture 5 8 / 13
  • 9. Continued– N t=1 rt xt = w0 N t=1 xt + w1 N t=1 (xt )2 (2) which can be written in vector-matrix form as Aw = y where A = N N t=1 xt N t=1 xt N t=1(xt)2 W = w0 w1 Hence, we can estimate the parameter w0 and w1 by estimator G(x|θ) using training set χ = {xt, rt} W = A−1 y Dr. Varun Kumar Lecture 5 9 / 13
  • 10. Linear Regression of Higher Order: Example: 1 Let a mathematical input-output relation is such a way that r = f (x) + b where unknown function f (x) is estimated by a linear estimator G(x|θ) = a1x1 + a2x2 + a3x3 + b where, x = {x1, x2, x3} and θ = {a1, a2, a3, b} training data set χ = {rt, xt 1, xt 2, xt 3}N t=1, respectively . Ans. Let us start with second question, where four unknown and total 5N number of training data N t=1 rt = bN + a1 N t=1 xt 1 + a2 N t=1 xt 2 + a3 N t=1 xt 3 (3) Dr. Varun Kumar Lecture 5 10 / 13
  • 11. Continued– N t=1 rt xt 1 = b N t=1 xt 1 + a1 N t=1 (xt 1)2 + a2 N t=1 xt 1xt 2 + a3 N t=1 xt 1xt 3 (4) N t=1 rt xt 2 = b N t=1 xt 2 + a1 N t=1 xt 2xt 1 + a2 N t=1 (xt 2)2 + a3 N t=1 xt 2xt 3 (5) N t=1 rt xt 3 = b N t=1 xt 3 + a1 N t=1 xt 3xt 1 + a2 N t=1 xt 3xt 2 + a3 N t=1 (xt 3)2 (6) From previous example, we can also express as AW = y where y = N t=1 rt, N t=1 rtxt 1, N t=1 rtxt 2, N t=1 rtxt 3 T Dr. Varun Kumar Lecture 5 11 / 13
  • 12. Quadratic or Polynomial Regression Quadratic or Polynomial Regression : For quadratic regression, our estimator can be modeled as G(x|θ) = a2x2 + a1x + a0 Here, θ = a2, a1, a0 For polynomial regression, our estimator can be modeled as G(x|θ) = anxn + an−1xn−1 + ..... + a0 Here, θ = an, an−1, ...., a0 Dr. Varun Kumar Lecture 5 12 / 13
  • 13. References E. Alpaydin, Introduction to machine learning. MIT press, 2020. T. M. Mitchell, The discipline of machine learning. Carnegie Mellon University, School of Computer Science, Machine Learning , 2006, vol. 9. J. Grus, Data science from scratch: first principles with python. O’Reilly Media, 2019. Dr. Varun Kumar Lecture 5 13 / 13