SlideShare a Scribd company logo
4
Most read
6
Most read
7
Most read
Lasso and ridge regression
The equation of a straight line is
 b = value of y when x=0 (intercept)
 m = Slope or Gradient (how steep the line is)
Reference: https://www.mathsisfun.com/equation_of_line.html
Linear regression is an approach to model the relationship between a dependent variable and one
or more independent variables.
 Linear Regression model try to create a linear
relationship between dependent (salary) and
independent (experience) variables.
 It try to create the equation of a straight line (salary =
m * experience + b) with minimum error (residual)
between actual value and predicted value.
 Equation for simple linear regression : y = m*x + b
 Equation for multiple linear regression : y = m1*x1 + m2*x2 + …. + mn*xn + b
Linear Regression tries to create best fit line with minimum
sum of residuals (∑ ( Y – Ypredict )^2) which is also known as
cost function.
Slope = 1
Intercept = 0
Slope = 0
Intercept = 0
Slope =
Undefined (1/0)
 In case of the lines having higher slope, any
minor variation in x can cause to a major
variation in y.
 In the linear regression model creating with
such data can have overfitting problem.
 One solution is to penalize the slopes and
make the model a generalized one.
 LASSO and RIDGE regression are models will
help for the same.
Underfitting occurs when a model can’t accurately
capture the dependencies among data, usually as a
consequence of its own simplicity. It often yields a
with known data and bad generalization
applied with new data.
Overfitting happens when a model learns both
dependencies among data and random
words, a model learns the existing data too well.
models usually yield high 𝑅². However, they often
generalize well and have significantly lower 𝑅²
with new data.
A good way to reduce overfitting is to regularize the model (i.e.,
to constrain it):
For a linear model, regularization is typically achieved by
constraining the weights of the model. Why?
The size of coefficients increase exponentially with increase in model
complexity
Techniques like Ridge Regression, Lasso Regression, and
Elastic Net, implement three different ways to constrain the
weights.
Least Absolute Shrinkage and Selection
Operator Regression (simply called Lasso
Regression) is another regularized version of
Linear Regression: that adds a L1
regularization term to the cost function,
The minimization objectives is MSE +  * | m |
Default value of alpha is 1. It can be zero to any positive
number.
Lasso Regression tends to completely
eliminate the weights of the least important
features (i.e., set them to zero).
Ridge Regression (also called Tikhonov
regularization) is a L2 regularized version of Linear
Regression: a regularization term equal to  *
slope^2 is added to the cost function.
The minimization objectives is MSE +  * m^2
This forces the learning algorithm to not only fit
the data but also keep the model weights as small
as possible.
Note that the regularization term should only be
added to the cost function during training.
The  (alpha) balance the amount of emphasis to the
regularization. Default value of alpha is 1. It can be
zero to any positive number.
 = 0  simple linear regression
 =   all coefficients become zero
increasing α leads to flatter (i.e., less extreme,
more reasonable) predictions.
Elastic net is a popular type of regularized linear regression that combines
two popular penalties, specifically the L1 and L2 penalty functions.
Similar to Ridge and LASSO Elastic Net is an extension of linear regression,
this adds regularization penalties to the loss function during training.
The penalty is a mixture of L1 and L2 penalties. Alpha and l1_ratio arguments
decides the same. Default value of alpha is 1 and can be passed according to
convenience of the data.
l1_ratio can have value from 0 to 1. Default value =0.5. l1_ratio = 0 means the
penalty is an L2 penalty. l1_ratio = 1 means it is an L1 penalty. l1_ratio is
between 0 and 1, the penalty is a combination of L1 and L2.
Reference: https://machinelearningmastery.com/elastic-net-regression-in-python/
Lasso and ridge regression

More Related Content

PDF
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
PDF
Ridge regression
PDF
Ridge regression, lasso and elastic net
PDF
Visual Explanation of Ridge Regression and LASSO
PPTX
Machine learning session4(linear regression)
PPTX
Regression ppt.pptx
PPTX
Regularization_BY_MOHAMED_ESSAM.pptx
PPTX
Linear regression
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Ridge regression
Ridge regression, lasso and elastic net
Visual Explanation of Ridge Regression and LASSO
Machine learning session4(linear regression)
Regression ppt.pptx
Regularization_BY_MOHAMED_ESSAM.pptx
Linear regression

What's hot (20)

PDF
Bayesian Networks - A Brief Introduction
PDF
Bayesian inference
PPTX
Logistic regression
PPTX
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
PDF
Dimensionality Reduction
PPTX
Support Vector Machine ppt presentation
PPTX
Machine Learning-Linear regression
PDF
Principal Component Analysis
PPTX
Logistic regression
PDF
Linear regression
PPT
Support Vector Machines
PPTX
ML - Multiple Linear Regression
PPTX
Bayesian Linear Regression.pptx
PPTX
ML - Simple Linear Regression
PPTX
Support vector machine
PDF
Lecture9 - Bayesian-Decision-Theory
ODP
Machine Learning With Logistic Regression
PPTX
Stochastic Gradient Decent (SGD).pptx
PPT
Clustering
PPTX
Naïve Bayes Classifier Algorithm.pptx
Bayesian Networks - A Brief Introduction
Bayesian inference
Logistic regression
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Dimensionality Reduction
Support Vector Machine ppt presentation
Machine Learning-Linear regression
Principal Component Analysis
Logistic regression
Linear regression
Support Vector Machines
ML - Multiple Linear Regression
Bayesian Linear Regression.pptx
ML - Simple Linear Regression
Support vector machine
Lecture9 - Bayesian-Decision-Theory
Machine Learning With Logistic Regression
Stochastic Gradient Decent (SGD).pptx
Clustering
Naïve Bayes Classifier Algorithm.pptx
Ad

Similar to Lasso and ridge regression (20)

PPTX
MF Presentation.pptx
PDF
lab_linear_regression_hy539 (1)_221109_035050.pdf
PPTX
Regularization concept in machine learning
PDF
The normal presentation about linear regression in machine learning
PPTX
Linear regression
PPTX
ML-UNIT-IV complete notes download here
PDF
Linear models for data science
PPTX
linear regression1.pptx machine learning
PPTX
Ot regularization and_gradient_descent
PDF
nber_slides.pdf
PPTX
PDF
Simple regression model
PPTX
Lec 09-10- -Regression Implementation.pptx
PPTX
Machine Learning Unit 3 Semester 3 MSc IT Part 2 Mumbai University
PPTX
MachineLearning_Unit-II.pptxScrum.pptxAgile Model.pptxAgile Model.pptxAgile M...
PDF
MachineLearning_Unit-II.FHDGFHJKpptx.pdf
PDF
Module 5.pdf Machine Learning Types and examples
PPTX
Arjrandomjjejejj3ejjeejjdjddjjdjdjdjdjdjdjdjdjd
PPTX
11Polynomial RegressionPolynomial RegressionPolynomial RegressionPolynomial R...
PDF
Sparsenet
MF Presentation.pptx
lab_linear_regression_hy539 (1)_221109_035050.pdf
Regularization concept in machine learning
The normal presentation about linear regression in machine learning
Linear regression
ML-UNIT-IV complete notes download here
Linear models for data science
linear regression1.pptx machine learning
Ot regularization and_gradient_descent
nber_slides.pdf
Simple regression model
Lec 09-10- -Regression Implementation.pptx
Machine Learning Unit 3 Semester 3 MSc IT Part 2 Mumbai University
MachineLearning_Unit-II.pptxScrum.pptxAgile Model.pptxAgile Model.pptxAgile M...
MachineLearning_Unit-II.FHDGFHJKpptx.pdf
Module 5.pdf Machine Learning Types and examples
Arjrandomjjejejj3ejjeejjdjddjjdjdjdjdjdjdjdjdjd
11Polynomial RegressionPolynomial RegressionPolynomial RegressionPolynomial R...
Sparsenet
Ad

More from SreerajVA (6)

PPSX
Logistic regression classification
PPSX
Linear regression
PPSX
KNN, SVM, Naive bayes classifiers
PPSX
Decision tree random forest classifier
PPSX
KMeans clustering
PPSX
ADABoost classifier
Logistic regression classification
Linear regression
KNN, SVM, Naive bayes classifiers
Decision tree random forest classifier
KMeans clustering
ADABoost classifier

Recently uploaded (20)

PDF
annual-report-2024-2025 original latest.
PPTX
Computer network topology notes for revision
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PPTX
1_Introduction to advance data techniques.pptx
PPTX
Introduction-to-Cloud-ComputingFinal.pptx
PDF
Foundation of Data Science unit number two notes
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
PPT
Quality review (1)_presentation of this 21
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
Database Infoormation System (DBIS).pptx
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPT
Reliability_Chapter_ presentation 1221.5784
annual-report-2024-2025 original latest.
Computer network topology notes for revision
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Introduction to Knowledge Engineering Part 1
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
1_Introduction to advance data techniques.pptx
Introduction-to-Cloud-ComputingFinal.pptx
Foundation of Data Science unit number two notes
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
ALIMENTARY AND BILIARY CONDITIONS 3-1.pptx
Quality review (1)_presentation of this 21
Supervised vs unsupervised machine learning algorithms
Database Infoormation System (DBIS).pptx
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
Reliability_Chapter_ presentation 1221.5784

Lasso and ridge regression

  • 2. The equation of a straight line is  b = value of y when x=0 (intercept)  m = Slope or Gradient (how steep the line is) Reference: https://www.mathsisfun.com/equation_of_line.html
  • 3. Linear regression is an approach to model the relationship between a dependent variable and one or more independent variables.  Linear Regression model try to create a linear relationship between dependent (salary) and independent (experience) variables.  It try to create the equation of a straight line (salary = m * experience + b) with minimum error (residual) between actual value and predicted value.  Equation for simple linear regression : y = m*x + b  Equation for multiple linear regression : y = m1*x1 + m2*x2 + …. + mn*xn + b Linear Regression tries to create best fit line with minimum sum of residuals (∑ ( Y – Ypredict )^2) which is also known as cost function.
  • 4. Slope = 1 Intercept = 0 Slope = 0 Intercept = 0 Slope = Undefined (1/0)  In case of the lines having higher slope, any minor variation in x can cause to a major variation in y.  In the linear regression model creating with such data can have overfitting problem.  One solution is to penalize the slopes and make the model a generalized one.  LASSO and RIDGE regression are models will help for the same. Underfitting occurs when a model can’t accurately capture the dependencies among data, usually as a consequence of its own simplicity. It often yields a with known data and bad generalization applied with new data. Overfitting happens when a model learns both dependencies among data and random words, a model learns the existing data too well. models usually yield high 𝑅². However, they often generalize well and have significantly lower 𝑅² with new data.
  • 5. A good way to reduce overfitting is to regularize the model (i.e., to constrain it): For a linear model, regularization is typically achieved by constraining the weights of the model. Why? The size of coefficients increase exponentially with increase in model complexity Techniques like Ridge Regression, Lasso Regression, and Elastic Net, implement three different ways to constrain the weights.
  • 6. Least Absolute Shrinkage and Selection Operator Regression (simply called Lasso Regression) is another regularized version of Linear Regression: that adds a L1 regularization term to the cost function, The minimization objectives is MSE +  * | m | Default value of alpha is 1. It can be zero to any positive number. Lasso Regression tends to completely eliminate the weights of the least important features (i.e., set them to zero).
  • 7. Ridge Regression (also called Tikhonov regularization) is a L2 regularized version of Linear Regression: a regularization term equal to  * slope^2 is added to the cost function. The minimization objectives is MSE +  * m^2 This forces the learning algorithm to not only fit the data but also keep the model weights as small as possible. Note that the regularization term should only be added to the cost function during training. The  (alpha) balance the amount of emphasis to the regularization. Default value of alpha is 1. It can be zero to any positive number.  = 0  simple linear regression  =   all coefficients become zero increasing α leads to flatter (i.e., less extreme, more reasonable) predictions.
  • 8. Elastic net is a popular type of regularized linear regression that combines two popular penalties, specifically the L1 and L2 penalty functions. Similar to Ridge and LASSO Elastic Net is an extension of linear regression, this adds regularization penalties to the loss function during training. The penalty is a mixture of L1 and L2 penalties. Alpha and l1_ratio arguments decides the same. Default value of alpha is 1 and can be passed according to convenience of the data. l1_ratio can have value from 0 to 1. Default value =0.5. l1_ratio = 0 means the penalty is an L2 penalty. l1_ratio = 1 means it is an L1 penalty. l1_ratio is between 0 and 1, the penalty is a combination of L1 and L2. Reference: https://machinelearningmastery.com/elastic-net-regression-in-python/