SlideShare a Scribd company logo
1 of 20
Chapter 08
Regression
Dr. Steffen Herbold
herbold@cs.uni-goettingen.de
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Outline
• Overview
• Linear Regression Models
• Comparison of Regression Models
• Summary
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Example of Regression
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Regression
Top Speed
Fuel
consumption
The General Problem
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Regression
The Formal Problem
• Object space
• 𝑂 = 𝑜𝑏𝑗𝑒𝑐𝑡1, 𝑜𝑏𝑗𝑒𝑐𝑡2, …
• Often infinite
• Representations of the objects in a (real valued) feature space
• ℱ = 𝜙 𝑜 , 𝑜 ∈ 𝑂 = 𝑥1, … , 𝑥𝑚 ∈ ℝ𝑚
= 𝑋
• „Independent“ variables
• Dependent variable
• 𝑓∗ 𝑜 = 𝑦 ∈ ℝ
• A regression function
• 𝑓: ℝ𝑚
→ ℝ
• Regression
• Finding an approximation for 𝑓
• Relationship between dependent and independent variable
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Independent
variable 𝑥
Dependent
variable y
Function 𝑓
Quality of Regressions
• Goal: Approximation of the dependent variable
• 𝑓∗ 𝑜 ≈ ℎ(𝜙 𝑜 )
 Use Test Data
• Structure is the same as training data
• Apply approximated regression function
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
𝝓(𝒐) 𝒇∗
(𝒐) 𝒇(𝝓 𝒐 )
Top Speed Engine Size Horse Power Weight Year value prediction
250 1.4 130 1254 2003 7.8 7.5
280 1.8 185 1430 2010 6.3 6.9
… … … … … …
How do you evaluate
𝑓∗
𝑜 ≈ 𝑓(𝜙 𝑜 )
Visual Comparison
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Perfect Prediction
 Deviation from blue line as visual
indicator for prediction quality
Good prediction. Data close
to blue line, regular pattern of
deviations
Allows insights into where
predictions are good/bad
Residuals
• Differences between predictions and actual values
• 𝑒𝑥 = 𝑦 − 𝑓(𝑥)
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Visual Comparison of a Bad Fit
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Measures for Regression Quality
• Mean Absolute Error (MAE)
• 𝑀𝐴𝐸 =
1
|𝑋| 𝑥∈𝑋 |𝑒𝑥|
• Mean Squared Error (MSE)
• 𝑀𝑆𝐸 =
1
|𝑋| 𝑥∈𝑋 𝑒𝑥
2
• R squared (𝑅2)
• Fraction of the variance that is explained by the regression
• 𝑅2 = 1 − 𝑥∈𝑋 𝑦−𝑓(𝑥) 2
𝑥∈𝑋 𝑦−𝑚𝑒𝑎𝑛 𝑦
2
• Adjusted R squared (𝑅2
)
• Takes number of features into account
• 𝑅2
= 1 − (1 − 𝑅2
)
|𝑋|−1
𝑋 −𝑚−1
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Outline
• Overview
• Linear Regression Models
• Comparison of Regression Models
• Summary
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Linear Regression
• Regression as a linear function
• 𝑦 = 𝑏0 + 𝑏1𝑥1 + ⋯ 𝑏𝑚𝑥𝑚
• 𝑏0 is the interception with the axis
• 𝑏1, … , 𝑏𝑚 are the linear coefficients
• Calculated with Ordinary Least Squares
• Optimizes MSE!
• min 𝑏0 + 𝑋𝑏 − 𝑦 2
2
• 𝑋 =
𝑥1,1 ⋯ 𝑥1,𝑚
⋮ ⋱ ⋮
𝑥𝑛,1 ⋯ 𝑥𝑛,𝑚
• 𝑏 = (𝑏1, … , 𝑏𝑚)
• 𝑦 = (𝑦1, … , 𝑦𝑛)
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Square of Euclidean distance
𝑛 is the number of instances in the training data
Ridge Regression
• Still a linear function
• OLS allows multiple solutions for 𝑛 > 𝑚
• Ridge regression penalizes solutions with large coefficients
• Calculated with Tikhonov regularization
• min 𝑏0 + 𝑋𝑏 − 𝑦 2
2
+ Γ𝑏 2
2
• We use Γ = 𝛼𝐼
• Use 𝛼 to regulate regularization strength
• min 𝑏0 + 𝑋𝑏 − 𝑦 2
2
+ 𝛼 𝑏 2
2
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Regularization Term
Identity matrix
Lasso Regression
• Still a linear function
• Penalizing large coefficient does not remove redundencies
• Extreme example: identical features that predict perfectly
• y = 𝑥1 = 𝑥2,
• Ridge
• 𝑏1 = 𝑏2 = 0.5
• One coefficient zero would be better
• 𝑏1 = 1, 𝑏2 = 0
• Lasso: Ridge with Manhattan norm
• min 𝑏0 + 𝑋𝑏 − 𝑦 2
2
+ 𝛼 𝑏 1
• Increases the likelihood of coefficients being exactly zero
• Selects relevant features
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Elastic Net Regression
• Still a linear function
• Lasso tends to select one of multiple correlated features at
random
• Potential loss of information
• Elastic Net combines Ridge and Lasso
• Keeps only relevant correlated features and minimizes coefficients
• Use ratio 𝜌 between alphas for assigning more weight to
Ridge/Lasso
• min 𝑏0 + 𝑋𝑏 − 𝑦 2
2
+ 𝜌 ⋅ 𝛼 𝑏 1
+
(1−𝜌)
2
𝛼 𝑏 2
2
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Outline
• Overview
• Linear Regression Models
• Comparison of Regression Models
• Summary
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Comparison of Regression Models
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
All models trained with the same data and almost same performance
Coefficient with
previously highest value
actually eliminated!
Smaller coefficient values
than OLS
Smaller coefficient values
than Lasso
Non-linear Regression
• Many relationships are not linear
• Polynomial Regression
• Support Vector Regression
• Neural Networks
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Outline
• Overview
• Linear Regression Models
• Comparison of Regression Models
• Summary
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science
Summary
• Regression finds relationships between independent and
dependent variables
• Linear regression as simple model often effective
• Regularization can improve solutions
• Lasso, Ridge, Elastic, …
• Many non-linear approaches
• Require care with the application
• Overfitting can be very easy
Introduction to Data Science
https://sherbold.github.io/intro-to-data-science

More Related Content

Similar to 08-Regression.pptx

Graph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahon
Graph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahonGraph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahon
Graph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahonChristopher Conlan
 
Graph Analysis Beyond Linear Algebra
Graph Analysis Beyond Linear AlgebraGraph Analysis Beyond Linear Algebra
Graph Analysis Beyond Linear AlgebraJason Riedy
 
Paper study: Learning to solve circuit sat
Paper study: Learning to solve circuit satPaper study: Learning to solve circuit sat
Paper study: Learning to solve circuit satChenYiHuang5
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica"FENG "GEORGE"" YU
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in spaceFaizan Shabbir
 
Exploiting the query structure for efficient join ordering in SPARQL queries
Exploiting the query structure for efficient join ordering in SPARQL queriesExploiting the query structure for efficient join ordering in SPARQL queries
Exploiting the query structure for efficient join ordering in SPARQL queriesLuiz Henrique Zambom Santana
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational modelATS SBGI MIRAJ
 
Calculus Review Session Brian Prest Duke University Nicholas School of the En...
Calculus Review Session Brian Prest Duke University Nicholas School of the En...Calculus Review Session Brian Prest Duke University Nicholas School of the En...
Calculus Review Session Brian Prest Duke University Nicholas School of the En...rofiho9697
 
Logistic Ordinal Regression
Logistic Ordinal RegressionLogistic Ordinal Regression
Logistic Ordinal RegressionSri Ambati
 
Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfssuseraae901
 
Least Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear SolverLeast Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear SolverJi-yong Kwon
 
hands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model traininghands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model trainingJaey Jeong
 
Deep Implicit Layers: Learning Structured Problems with Neural Networks
Deep Implicit Layers: Learning Structured Problems with Neural NetworksDeep Implicit Layers: Learning Structured Problems with Neural Networks
Deep Implicit Layers: Learning Structured Problems with Neural NetworksSangwoo Mo
 
General Tips for participating Kaggle Competitions
General Tips for participating Kaggle CompetitionsGeneral Tips for participating Kaggle Competitions
General Tips for participating Kaggle CompetitionsMark Peng
 

Similar to 08-Regression.pptx (20)

Graph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahon
Graph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahonGraph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahon
Graph Algorithms, Sparse Algebra, and the GraphBLAS with Janice McMahon
 
Graph Analysis Beyond Linear Algebra
Graph Analysis Beyond Linear AlgebraGraph Analysis Beyond Linear Algebra
Graph Analysis Beyond Linear Algebra
 
Paper study: Learning to solve circuit sat
Paper study: Learning to solve circuit satPaper study: Learning to solve circuit sat
Paper study: Learning to solve circuit sat
 
Query Optimization - Brandon Latronica
Query Optimization - Brandon LatronicaQuery Optimization - Brandon Latronica
Query Optimization - Brandon Latronica
 
Lines and planes in space
Lines and planes in spaceLines and planes in space
Lines and planes in space
 
Exploiting the query structure for efficient join ordering in SPARQL queries
Exploiting the query structure for efficient join ordering in SPARQL queriesExploiting the query structure for efficient join ordering in SPARQL queries
Exploiting the query structure for efficient join ordering in SPARQL queries
 
Linear regression
Linear regressionLinear regression
Linear regression
 
Intro to relational model
Intro to relational modelIntro to relational model
Intro to relational model
 
Calculus Review Session Brian Prest Duke University Nicholas School of the En...
Calculus Review Session Brian Prest Duke University Nicholas School of the En...Calculus Review Session Brian Prest Duke University Nicholas School of the En...
Calculus Review Session Brian Prest Duke University Nicholas School of the En...
 
Logistic Ordinal Regression
Logistic Ordinal RegressionLogistic Ordinal Regression
Logistic Ordinal Regression
 
Engineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdfEngineering Numerical Analysis-Introduction.pdf
Engineering Numerical Analysis-Introduction.pdf
 
Data Mining Lecture_9.pptx
Data Mining Lecture_9.pptxData Mining Lecture_9.pptx
Data Mining Lecture_9.pptx
 
Relaxation method
Relaxation methodRelaxation method
Relaxation method
 
Least Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear SolverLeast Square Optimization and Sparse-Linear Solver
Least Square Optimization and Sparse-Linear Solver
 
hands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model traininghands on machine learning Chapter 4 model training
hands on machine learning Chapter 4 model training
 
An introduction to R
An introduction to RAn introduction to R
An introduction to R
 
SVD.ppt
SVD.pptSVD.ppt
SVD.ppt
 
Deep Implicit Layers: Learning Structured Problems with Neural Networks
Deep Implicit Layers: Learning Structured Problems with Neural NetworksDeep Implicit Layers: Learning Structured Problems with Neural Networks
Deep Implicit Layers: Learning Structured Problems with Neural Networks
 
Contour Forest
Contour Forest Contour Forest
Contour Forest
 
General Tips for participating Kaggle Competitions
General Tips for participating Kaggle CompetitionsGeneral Tips for participating Kaggle Competitions
General Tips for participating Kaggle Competitions
 

More from Shree Shree

More from Shree Shree (20)

10 rectangular options.pptx
10 rectangular options.pptx10 rectangular options.pptx
10 rectangular options.pptx
 
1732002B.pptx
1732002B.pptx1732002B.pptx
1732002B.pptx
 
9D52BDFC.pptx
9D52BDFC.pptx9D52BDFC.pptx
9D52BDFC.pptx
 
865FC50.pptx
865FC50.pptx865FC50.pptx
865FC50.pptx
 
9DE46AD6.pptx
9DE46AD6.pptx9DE46AD6.pptx
9DE46AD6.pptx
 
20DE6DE0.pptx
20DE6DE0.pptx20DE6DE0.pptx
20DE6DE0.pptx
 
2108-EN-TP-PhenomEssentialTalentAcquisitionToolkit.pdf
2108-EN-TP-PhenomEssentialTalentAcquisitionToolkit.pdf2108-EN-TP-PhenomEssentialTalentAcquisitionToolkit.pdf
2108-EN-TP-PhenomEssentialTalentAcquisitionToolkit.pdf
 
2C0A56C5.pptx
2C0A56C5.pptx2C0A56C5.pptx
2C0A56C5.pptx
 
1EF5E174.pptx
1EF5E174.pptx1EF5E174.pptx
1EF5E174.pptx
 
1BB40E18.pptx
1BB40E18.pptx1BB40E18.pptx
1BB40E18.pptx
 
8D0ECBB0.pptx
8D0ECBB0.pptx8D0ECBB0.pptx
8D0ECBB0.pptx
 
D1586BA6.pptx
D1586BA6.pptxD1586BA6.pptx
D1586BA6.pptx
 
FB09958.pptx
FB09958.pptxFB09958.pptx
FB09958.pptx
 
13072EF.pptx
13072EF.pptx13072EF.pptx
13072EF.pptx
 
E65B78F3.pptx
E65B78F3.pptxE65B78F3.pptx
E65B78F3.pptx
 
355C162.pptx
355C162.pptx355C162.pptx
355C162.pptx
 
795589F6.pptx
795589F6.pptx795589F6.pptx
795589F6.pptx
 
AD177DF3.pptx
AD177DF3.pptxAD177DF3.pptx
AD177DF3.pptx
 
961F1B3A.pptx
961F1B3A.pptx961F1B3A.pptx
961F1B3A.pptx
 
5F2D461.pptx
5F2D461.pptx5F2D461.pptx
5F2D461.pptx
 

Recently uploaded

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxShobhayan Kirtania
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
The byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptxThe byproduct of sericulture in different industries.pptx
The byproduct of sericulture in different industries.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

08-Regression.pptx

  • 1. Chapter 08 Regression Dr. Steffen Herbold herbold@cs.uni-goettingen.de Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 2. Outline • Overview • Linear Regression Models • Comparison of Regression Models • Summary Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 3. Example of Regression Introduction to Data Science https://sherbold.github.io/intro-to-data-science Regression Top Speed Fuel consumption
  • 4. The General Problem Introduction to Data Science https://sherbold.github.io/intro-to-data-science Regression
  • 5. The Formal Problem • Object space • 𝑂 = 𝑜𝑏𝑗𝑒𝑐𝑡1, 𝑜𝑏𝑗𝑒𝑐𝑡2, … • Often infinite • Representations of the objects in a (real valued) feature space • ℱ = 𝜙 𝑜 , 𝑜 ∈ 𝑂 = 𝑥1, … , 𝑥𝑚 ∈ ℝ𝑚 = 𝑋 • „Independent“ variables • Dependent variable • 𝑓∗ 𝑜 = 𝑦 ∈ ℝ • A regression function • 𝑓: ℝ𝑚 → ℝ • Regression • Finding an approximation for 𝑓 • Relationship between dependent and independent variable Introduction to Data Science https://sherbold.github.io/intro-to-data-science Independent variable 𝑥 Dependent variable y Function 𝑓
  • 6. Quality of Regressions • Goal: Approximation of the dependent variable • 𝑓∗ 𝑜 ≈ ℎ(𝜙 𝑜 )  Use Test Data • Structure is the same as training data • Apply approximated regression function Introduction to Data Science https://sherbold.github.io/intro-to-data-science 𝝓(𝒐) 𝒇∗ (𝒐) 𝒇(𝝓 𝒐 ) Top Speed Engine Size Horse Power Weight Year value prediction 250 1.4 130 1254 2003 7.8 7.5 280 1.8 185 1430 2010 6.3 6.9 … … … … … … How do you evaluate 𝑓∗ 𝑜 ≈ 𝑓(𝜙 𝑜 )
  • 7. Visual Comparison Introduction to Data Science https://sherbold.github.io/intro-to-data-science Perfect Prediction  Deviation from blue line as visual indicator for prediction quality Good prediction. Data close to blue line, regular pattern of deviations Allows insights into where predictions are good/bad
  • 8. Residuals • Differences between predictions and actual values • 𝑒𝑥 = 𝑦 − 𝑓(𝑥) Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 9. Visual Comparison of a Bad Fit Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 10. Measures for Regression Quality • Mean Absolute Error (MAE) • 𝑀𝐴𝐸 = 1 |𝑋| 𝑥∈𝑋 |𝑒𝑥| • Mean Squared Error (MSE) • 𝑀𝑆𝐸 = 1 |𝑋| 𝑥∈𝑋 𝑒𝑥 2 • R squared (𝑅2) • Fraction of the variance that is explained by the regression • 𝑅2 = 1 − 𝑥∈𝑋 𝑦−𝑓(𝑥) 2 𝑥∈𝑋 𝑦−𝑚𝑒𝑎𝑛 𝑦 2 • Adjusted R squared (𝑅2 ) • Takes number of features into account • 𝑅2 = 1 − (1 − 𝑅2 ) |𝑋|−1 𝑋 −𝑚−1 Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 11. Outline • Overview • Linear Regression Models • Comparison of Regression Models • Summary Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 12. Linear Regression • Regression as a linear function • 𝑦 = 𝑏0 + 𝑏1𝑥1 + ⋯ 𝑏𝑚𝑥𝑚 • 𝑏0 is the interception with the axis • 𝑏1, … , 𝑏𝑚 are the linear coefficients • Calculated with Ordinary Least Squares • Optimizes MSE! • min 𝑏0 + 𝑋𝑏 − 𝑦 2 2 • 𝑋 = 𝑥1,1 ⋯ 𝑥1,𝑚 ⋮ ⋱ ⋮ 𝑥𝑛,1 ⋯ 𝑥𝑛,𝑚 • 𝑏 = (𝑏1, … , 𝑏𝑚) • 𝑦 = (𝑦1, … , 𝑦𝑛) Introduction to Data Science https://sherbold.github.io/intro-to-data-science Square of Euclidean distance 𝑛 is the number of instances in the training data
  • 13. Ridge Regression • Still a linear function • OLS allows multiple solutions for 𝑛 > 𝑚 • Ridge regression penalizes solutions with large coefficients • Calculated with Tikhonov regularization • min 𝑏0 + 𝑋𝑏 − 𝑦 2 2 + Γ𝑏 2 2 • We use Γ = 𝛼𝐼 • Use 𝛼 to regulate regularization strength • min 𝑏0 + 𝑋𝑏 − 𝑦 2 2 + 𝛼 𝑏 2 2 Introduction to Data Science https://sherbold.github.io/intro-to-data-science Regularization Term Identity matrix
  • 14. Lasso Regression • Still a linear function • Penalizing large coefficient does not remove redundencies • Extreme example: identical features that predict perfectly • y = 𝑥1 = 𝑥2, • Ridge • 𝑏1 = 𝑏2 = 0.5 • One coefficient zero would be better • 𝑏1 = 1, 𝑏2 = 0 • Lasso: Ridge with Manhattan norm • min 𝑏0 + 𝑋𝑏 − 𝑦 2 2 + 𝛼 𝑏 1 • Increases the likelihood of coefficients being exactly zero • Selects relevant features Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 15. Elastic Net Regression • Still a linear function • Lasso tends to select one of multiple correlated features at random • Potential loss of information • Elastic Net combines Ridge and Lasso • Keeps only relevant correlated features and minimizes coefficients • Use ratio 𝜌 between alphas for assigning more weight to Ridge/Lasso • min 𝑏0 + 𝑋𝑏 − 𝑦 2 2 + 𝜌 ⋅ 𝛼 𝑏 1 + (1−𝜌) 2 𝛼 𝑏 2 2 Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 16. Outline • Overview • Linear Regression Models • Comparison of Regression Models • Summary Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 17. Comparison of Regression Models Introduction to Data Science https://sherbold.github.io/intro-to-data-science All models trained with the same data and almost same performance Coefficient with previously highest value actually eliminated! Smaller coefficient values than OLS Smaller coefficient values than Lasso
  • 18. Non-linear Regression • Many relationships are not linear • Polynomial Regression • Support Vector Regression • Neural Networks Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 19. Outline • Overview • Linear Regression Models • Comparison of Regression Models • Summary Introduction to Data Science https://sherbold.github.io/intro-to-data-science
  • 20. Summary • Regression finds relationships between independent and dependent variables • Linear regression as simple model often effective • Regularization can improve solutions • Lasso, Ridge, Elastic, … • Many non-linear approaches • Require care with the application • Overfitting can be very easy Introduction to Data Science https://sherbold.github.io/intro-to-data-science