SlideShare uma empresa Scribd logo
1 de 3
Baixar para ler offline
LINEAR REGRESSION WITH ONE OR MORE VARIABLES
TADEU FERREIRA DE SOUSA JÚNIOR
DATA SCIENCE INSIGHTS BLOG, SÃO PAULO, BRAZIL
HTTP://DATASCIENCEINSIGHTS.BLOGSPOT.COM
1. Introduction
Regression analysis is a method for investigating functional
relationships among variables. The relationship is expressed
in the form of an equation or a model connecting the re-
sponse or dependent variable and one or more explanatory
or predictor variables.
We denote the response variable by y and the set of
predictor variables by nxxx ,,, 21  , where n denotes the
number of predictor variables. The true relationship between
y and nxxx ,,, 21  can be approximated by the regres-
sion model or hypothesis function:
   nxxxfy ,,, 21 
An example is the linear regression model:
  nn xxxy 22110
Where n ,,, 10  are called the regression parame-
ters or coefficients, are unknown constants to be determined
(estimated) from the data and  is the error.
2. Linear Regression Model with One Variable or
Univariate Linear Regression
In the linear regression model with one variable, the rela-
tionship between a response variable Y and a predictor vari-
able X is postulated as a linear model or the hypothesis
function with one variable:
    110 xxhy
Cost Function
The accuracy of the hypothesis function is measured by the
cost function. This function is called the “Squared error
function” or Mean squared error. It takes an average of all
the results of the hypothesis with inputs from X compared
to the actual output Y :
   
   
 

m
i
ii
yxh
m
J
1
2
10
2
1
, 
Where mis the size of the data. The accuracy of the hy-
pothesis function is measured by the cost function. The
m2
1 part is for mathematical convenience as the deriva-
tive term of the square function will cancel out the
2
1 term.
3. Gradient Descent or Steepest Descent for Line-
ar Regression with One Variable
For the linear regression, the gradient descent will be used to
find the parameters that minimizes the cost function.
min  10 ,J
 10
1
0
1
1
1
0
,




Ji
i
i
i














Deriving the expression
 
   
 
 
   
   
































m
i
iii
m
i
ii
i
i
i
i
xyxh
yxh
m
1
1
1
0
1
1
1
0







4. Linear Regression Model with Multiple Varia-
bles or Multivariate Linear Regression
The relationship between the response variable and the pre-
dictor values is given by
 
  xθT
nn
xhy
xxxxhy



  ...22110
Where
 n
T
 210θ ,

















nx
x
x

2
1
1
x
Cost Function
   
   
 

m
i
ii
yxh
m
J
1
2
2
1
: θ
The parameters that minimizes the cost function are ex-
pressed as
 
   
   






 
m
i
i
j
ii
jj xyxh
m 1
: 


 
   
   






 
m
i
iii
yh
m 1
: xxθθ 

It’s necessary to update simultaneously j for
nj ,,0  .
5. Univariate Linear Regression Application
As an application example, it’s given an input data x
and an output data y , shown as a scatter plot.
Figure 1- Scatter plot of the data
For the initial conditions, the learning rate  is chosen
0.02 and the guesses for the parameters are chosen as












0
0
1
0


.
Applying the Gradient Descent algorithm, it’s expected
the cost to decrease. As a stop criterion, it’s chosen the cost
value between the iterations to be greater than a small value
 . That means:
 ii CostCost 1
In this example  =
7
10
.
Figure 2 - Cost
At the end of the iterations, the predictors values  are
determined.












1.1917984
3.8834860-
1
0


Hence, the estimated linear function for y is defined as
y -3.8834860 + 1.1917984 x
Figure 3 - Estimated linear function
6. Multivariate Linear Regression Application
It’s given an 2-dimensional input data x and an output
data y , shown as a scatter plot in figures 4 and 5.
Figure 4 - Scatter plot of the data
Figure 5 - Scatter plot of the data
For the initial conditions, the learning rate  is chosen
1.0 and the guesses for the parameters are chosen as





















0
0
0
2
1
0



.
Applying the Gradient Descent algorithm with  =
7
10
, the cost function decreases as shown in figure 6.
Figure 6 - Cost Function
At the end of the iterations, the predictors values  are
determined.





















0.0665-
1.1063
3.4041
105
2
1
0



Hence, the estimated linear function for y is defined as
y 3.4041∙105
+ 1.1063∙105
1x - 0.0665∙105
2x
Figure 7 - Estimated points
Figure 8 - Estimated points
7. References
CHATTERJEE,S., HADI, A.S. 2006. Regression
Analysis by Example, Fourth Edition. John Wiley &
Sons. 2006.
RAO, S.S. 2009. Engineering Optimization: Theory
and Practice, Fourth Edition, John Wiley & Sons. 2009.
Machine Learning. Coursera.com

Mais conteúdo relacionado

Mais procurados

Multivariate Regression Analysis
Multivariate Regression AnalysisMultivariate Regression Analysis
Multivariate Regression AnalysisKalaivanan Murthy
 
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
 
Determinants
DeterminantsDeterminants
DeterminantsRivan001
 
Linear Regression and Logistic Regression in ML
Linear Regression and Logistic Regression in MLLinear Regression and Logistic Regression in ML
Linear Regression and Logistic Regression in MLKumud Arora
 
Lesson 6 coefficient of determination
Lesson 6   coefficient of determinationLesson 6   coefficient of determination
Lesson 6 coefficient of determinationMehediHasan1023
 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear RegressionAndrew Ferlitsch
 
Regression Analysis presentation by Al Arizmendez and Cathryn Lottier
Regression Analysis presentation by Al Arizmendez and Cathryn LottierRegression Analysis presentation by Al Arizmendez and Cathryn Lottier
Regression Analysis presentation by Al Arizmendez and Cathryn LottierAl Arizmendez
 
Bivariate linear regression
Bivariate linear regressionBivariate linear regression
Bivariate linear regressionMenaal Kaushal
 
Modified Distribution Method (MODI)
Modified Distribution Method (MODI)Modified Distribution Method (MODI)
Modified Distribution Method (MODI)Cool Guy
 
Gauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial PivotingGauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial PivotingSM. Aurnob
 
Limit, Continuity and Differentiability for JEE Main 2014
Limit, Continuity and Differentiability for JEE Main 2014Limit, Continuity and Differentiability for JEE Main 2014
Limit, Continuity and Differentiability for JEE Main 2014Ednexa
 

Mais procurados (20)

Multivariate Regression Analysis
Multivariate Regression AnalysisMultivariate Regression Analysis
Multivariate Regression Analysis
 
Chap11 simple regression
Chap11 simple regressionChap11 simple regression
Chap11 simple regression
 
Linear regression
Linear regressionLinear regression
Linear regression
 
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 analysis
Regression analysisRegression analysis
Regression analysis
 
Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
 
Determinants
DeterminantsDeterminants
Determinants
 
Webdec2
Webdec2Webdec2
Webdec2
 
Regression
RegressionRegression
Regression
 
Linear Regression and Logistic Regression in ML
Linear Regression and Logistic Regression in MLLinear Regression and Logistic Regression in ML
Linear Regression and Logistic Regression in ML
 
Regression
RegressionRegression
Regression
 
Lesson 6 coefficient of determination
Lesson 6   coefficient of determinationLesson 6   coefficient of determination
Lesson 6 coefficient of determination
 
ML - Simple Linear Regression
ML - Simple Linear RegressionML - Simple Linear Regression
ML - Simple Linear Regression
 
Regression Analysis presentation by Al Arizmendez and Cathryn Lottier
Regression Analysis presentation by Al Arizmendez and Cathryn LottierRegression Analysis presentation by Al Arizmendez and Cathryn Lottier
Regression Analysis presentation by Al Arizmendez and Cathryn Lottier
 
Bivariate linear regression
Bivariate linear regressionBivariate linear regression
Bivariate linear regression
 
Regression
RegressionRegression
Regression
 
Modified Distribution Method (MODI)
Modified Distribution Method (MODI)Modified Distribution Method (MODI)
Modified Distribution Method (MODI)
 
Gauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial PivotingGauss Elimination Method With Partial Pivoting
Gauss Elimination Method With Partial Pivoting
 
Limit, Continuity and Differentiability for JEE Main 2014
Limit, Continuity and Differentiability for JEE Main 2014Limit, Continuity and Differentiability for JEE Main 2014
Limit, Continuity and Differentiability for JEE Main 2014
 
Regression Analysis
Regression AnalysisRegression Analysis
Regression Analysis
 

Semelhante a Linear Regression With One or More Variables

Lecture - 8 MLR.pptx
Lecture - 8 MLR.pptxLecture - 8 MLR.pptx
Lecture - 8 MLR.pptxiris765749
 
Simple lin regress_inference
Simple lin regress_inferenceSimple lin regress_inference
Simple lin regress_inferenceKemal İnciroğlu
 
Propagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace ReductionPropagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace ReductionMohammad
 
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, InterpolationApplied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, InterpolationBrian Erandio
 
Econometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse ModelsEconometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse ModelsNBER
 
Polynomial regression model of making cost prediction in mixed cost analysis
Polynomial regression model of making cost prediction in mixed cost analysisPolynomial regression model of making cost prediction in mixed cost analysis
Polynomial regression model of making cost prediction in mixed cost analysisAlexander Decker
 
11.polynomial regression model of making cost prediction in mixed cost analysis
11.polynomial regression model of making cost prediction in mixed cost analysis11.polynomial regression model of making cost prediction in mixed cost analysis
11.polynomial regression model of making cost prediction in mixed cost analysisAlexander Decker
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)ijceronline
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegressionDaniel K
 
Exploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectExploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectSurya Chandra
 
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdfOke Temitope
 
Regression Analysis by Muthama JM
Regression Analysis by Muthama JM Regression Analysis by Muthama JM
Regression Analysis by Muthama JM Japheth Muthama
 
Regression analysis by Muthama JM
Regression analysis by Muthama JMRegression analysis by Muthama JM
Regression analysis by Muthama JMJapheth Muthama
 
Correation, Linear Regression and Multilinear Regression using R software
Correation, Linear Regression and Multilinear Regression using R softwareCorreation, Linear Regression and Multilinear Regression using R software
Correation, Linear Regression and Multilinear Regression using R softwareshrikrishna kesharwani
 
A Novel Cosine Approximation for High-Speed Evaluation of DCT
A Novel Cosine Approximation for High-Speed Evaluation of DCTA Novel Cosine Approximation for High-Speed Evaluation of DCT
A Novel Cosine Approximation for High-Speed Evaluation of DCTCSCJournals
 

Semelhante a Linear Regression With One or More Variables (20)

Lecture - 8 MLR.pptx
Lecture - 8 MLR.pptxLecture - 8 MLR.pptx
Lecture - 8 MLR.pptx
 
ML Module 3.pdf
ML Module 3.pdfML Module 3.pdf
ML Module 3.pdf
 
Regression
RegressionRegression
Regression
 
Regression
RegressionRegression
Regression
 
ch02.pdf
ch02.pdfch02.pdf
ch02.pdf
 
Simple lin regress_inference
Simple lin regress_inferenceSimple lin regress_inference
Simple lin regress_inference
 
Propagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace ReductionPropagation of Error Bounds due to Active Subspace Reduction
Propagation of Error Bounds due to Active Subspace Reduction
 
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, InterpolationApplied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
 
Econometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse ModelsEconometrics of High-Dimensional Sparse Models
Econometrics of High-Dimensional Sparse Models
 
Regression
Regression  Regression
Regression
 
Polynomial regression model of making cost prediction in mixed cost analysis
Polynomial regression model of making cost prediction in mixed cost analysisPolynomial regression model of making cost prediction in mixed cost analysis
Polynomial regression model of making cost prediction in mixed cost analysis
 
11.polynomial regression model of making cost prediction in mixed cost analysis
11.polynomial regression model of making cost prediction in mixed cost analysis11.polynomial regression model of making cost prediction in mixed cost analysis
11.polynomial regression model of making cost prediction in mixed cost analysis
 
International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)International Journal of Computational Engineering Research(IJCER)
International Journal of Computational Engineering Research(IJCER)
 
SupportVectorRegression
SupportVectorRegressionSupportVectorRegression
SupportVectorRegression
 
Exploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems ProjectExploring Support Vector Regression - Signals and Systems Project
Exploring Support Vector Regression - Signals and Systems Project
 
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
6_nome_e_numero_Chapra_Canale_1998_Numerical_Differentiation_and_Integration.pdf
 
Regression Analysis by Muthama JM
Regression Analysis by Muthama JM Regression Analysis by Muthama JM
Regression Analysis by Muthama JM
 
Regression analysis by Muthama JM
Regression analysis by Muthama JMRegression analysis by Muthama JM
Regression analysis by Muthama JM
 
Correation, Linear Regression and Multilinear Regression using R software
Correation, Linear Regression and Multilinear Regression using R softwareCorreation, Linear Regression and Multilinear Regression using R software
Correation, Linear Regression and Multilinear Regression using R software
 
A Novel Cosine Approximation for High-Speed Evaluation of DCT
A Novel Cosine Approximation for High-Speed Evaluation of DCTA Novel Cosine Approximation for High-Speed Evaluation of DCT
A Novel Cosine Approximation for High-Speed Evaluation of DCT
 

Último

Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Valters Lauzums
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...amitlee9823
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...amitlee9823
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxolyaivanovalion
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightDelhi Call girls
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Researchmichael115558
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAroojKhan71
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 

Último (20)

Sampling (random) method and Non random.ppt
Sampling (random) method and Non random.pptSampling (random) method and Non random.ppt
Sampling (random) method and Non random.ppt
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
Chintamani Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore ...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Zuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptxZuja dropshipping via API with DroFx.pptx
Zuja dropshipping via API with DroFx.pptx
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 nightCheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
Cheap Rate Call girls Sarita Vihar Delhi 9205541914 shot 1500 night
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 

Linear Regression With One or More Variables

  • 1. LINEAR REGRESSION WITH ONE OR MORE VARIABLES TADEU FERREIRA DE SOUSA JÚNIOR DATA SCIENCE INSIGHTS BLOG, SÃO PAULO, BRAZIL HTTP://DATASCIENCEINSIGHTS.BLOGSPOT.COM 1. Introduction Regression analysis is a method for investigating functional relationships among variables. The relationship is expressed in the form of an equation or a model connecting the re- sponse or dependent variable and one or more explanatory or predictor variables. We denote the response variable by y and the set of predictor variables by nxxx ,,, 21  , where n denotes the number of predictor variables. The true relationship between y and nxxx ,,, 21  can be approximated by the regres- sion model or hypothesis function:    nxxxfy ,,, 21  An example is the linear regression model:   nn xxxy 22110 Where n ,,, 10  are called the regression parame- ters or coefficients, are unknown constants to be determined (estimated) from the data and  is the error. 2. Linear Regression Model with One Variable or Univariate Linear Regression In the linear regression model with one variable, the rela- tionship between a response variable Y and a predictor vari- able X is postulated as a linear model or the hypothesis function with one variable:     110 xxhy Cost Function The accuracy of the hypothesis function is measured by the cost function. This function is called the “Squared error function” or Mean squared error. It takes an average of all the results of the hypothesis with inputs from X compared to the actual output Y :            m i ii yxh m J 1 2 10 2 1 ,  Where mis the size of the data. The accuracy of the hy- pothesis function is measured by the cost function. The m2 1 part is for mathematical convenience as the deriva- tive term of the square function will cancel out the 2 1 term. 3. Gradient Descent or Steepest Descent for Line- ar Regression with One Variable For the linear regression, the gradient descent will be used to find the parameters that minimizes the cost function. min  10 ,J  10 1 0 1 1 1 0 ,     Ji i i i               Deriving the expression                                                   m i iii m i ii i i i i xyxh yxh m 1 1 1 0 1 1 1 0        4. Linear Regression Model with Multiple Varia- bles or Multivariate Linear Regression The relationship between the response variable and the pre- dictor values is given by     xθT nn xhy xxxxhy      ...22110 Where  n T  210θ ,                  nx x x  2 1 1 x
  • 2. Cost Function            m i ii yxh m J 1 2 2 1 : θ The parameters that minimizes the cost function are ex- pressed as                   m i i j ii jj xyxh m 1 :                      m i iii yh m 1 : xxθθ   It’s necessary to update simultaneously j for nj ,,0  . 5. Univariate Linear Regression Application As an application example, it’s given an input data x and an output data y , shown as a scatter plot. Figure 1- Scatter plot of the data For the initial conditions, the learning rate  is chosen 0.02 and the guesses for the parameters are chosen as             0 0 1 0   . Applying the Gradient Descent algorithm, it’s expected the cost to decrease. As a stop criterion, it’s chosen the cost value between the iterations to be greater than a small value  . That means:  ii CostCost 1 In this example  = 7 10 . Figure 2 - Cost At the end of the iterations, the predictors values  are determined.             1.1917984 3.8834860- 1 0   Hence, the estimated linear function for y is defined as y -3.8834860 + 1.1917984 x Figure 3 - Estimated linear function 6. Multivariate Linear Regression Application It’s given an 2-dimensional input data x and an output data y , shown as a scatter plot in figures 4 and 5.
  • 3. Figure 4 - Scatter plot of the data Figure 5 - Scatter plot of the data For the initial conditions, the learning rate  is chosen 1.0 and the guesses for the parameters are chosen as                      0 0 0 2 1 0    . Applying the Gradient Descent algorithm with  = 7 10 , the cost function decreases as shown in figure 6. Figure 6 - Cost Function At the end of the iterations, the predictors values  are determined.                      0.0665- 1.1063 3.4041 105 2 1 0    Hence, the estimated linear function for y is defined as y 3.4041∙105 + 1.1063∙105 1x - 0.0665∙105 2x Figure 7 - Estimated points Figure 8 - Estimated points 7. References CHATTERJEE,S., HADI, A.S. 2006. Regression Analysis by Example, Fourth Edition. John Wiley & Sons. 2006. RAO, S.S. 2009. Engineering Optimization: Theory and Practice, Fourth Edition, John Wiley & Sons. 2009. Machine Learning. Coursera.com