The Wayback Machine - https://web.archive.org/web/20250329184724/https://www.geeksforgeeks.org/what-is-lasso-regression/
Open In App

What is Lasso Regression?

Last Updated : 27 Mar, 2025
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

Lasso Regression is a regression method based on Least Absolute Shrinkage and Selection Operator and its an important technique in regression analysis for variables selection and regularization. It helps remove irrelevant data features and preventing overfitting. This allows features with weak influence to be clearly identified as the coefficients of less important variables are shrunk toward zero.

In this guide, we will understand the core concepts of lasso regression as well as how it works to mitigate overfitting.

Understanding Lasso Regression

Lasso (Least Absolute Shrinkage and Selection Operator) regression typically belongs to regularization techniques category, which is usually applied to avoid overfitting. Lasso Regression enhance the linear regression concept by making use of a regularization process in the standard regression equation. Linear Regression operates by minimizing the sum of squared discrepancies between the observed and predicted values by fitting a line to the data points.

However, multicollinearity is a condition in which features have a strong correlation with one another occurs in real-words datasets. This is when the regularization approach of Lasso Regression comes in handy. Regularization in simple term add penalty term to model preventing it from overfitting.

For example if you're attempting with a model to forecast house prices based on features such as location, square footage and the number of bedrooms.

Lasso Regression will let us determine which feature is more important or whereas location and square footage are major determinants of price. By zeroing out the coefficient for the bedroom feature it simplifies the model in order to increase the model accuracy.

Bias-Variance Tradeoff in Lasso Regression

The balance between bias (error resulting from oversimplified assumptions in the model) and variance (error resulting from sensitivity to little variations in the training data) is known as the bias-variance tradeoff.

When implementing Lasso Regression, the penalty term i.e., L1 regularization helps lower the variance of the model by shrinking the coefficients of less significant features towards zero. This reduces the chance of overfitting where the model identifies noise in the training set instead of the underlying patterns.

However, increasing the regularization strength (i.e., raising the lambda value) may increase bias. This happens because a stronger penalty can cause the model to oversimplify, making it unable to capture the true relationships in the data.

Thus, bias and variance are traded off in lasso regression just like in other regularization strategies. Achieving the ideal balance usually entails minimizing the total prediction error by adjusting the regularization parameter using methods like cross-validation.

bias-varianec-trade-off1-copy
Bias Variance Tradeoff

Understanding Lasso Regression Working

Lasso regression is fundamentally an extension of linear regression. The goal of traditional linear regression is to minimize the sum of squared differences between the observed and predicted values in order to determine the line that best fits the data points.

But the complexity of real-world data is not taken into account by linear regression, particularly when there are many factors.

1. Ordinary Least Squares (OLS) Regression

Lasso regression builds on the Ordinary Least Squares (OLS) Regression method by adding a penalty term. The basic equation for OLS is:

min RSS = Σ(yᵢ - ŷᵢ)²

Where

  • y_i is the observed value.
  • ŷᵢ is the predicted value for each data point i.

2. Penalty Term for Lasso Regression

In Lasso regression, a penalty term is added to the OLS equation. The penalty is the sum of the absolute values of the coefficients. The updated cost function becomes:

RSS + \lambda \times \sum |\beta_i|

Where,

  • \beta_i represents the coefficients of the predictors
  • \lambda is the tuning parameter that controls the strength of the penalty. As \lambda increases more coefficients are pushed towards zero

3. Shrinking Coefficients:

The key feature of Lasso regression is its ability to shrink the coefficients of less significant features to zero. This effectively removes these features from the model performing variable selection. This is particularly useful when working with high-dimensional data where there are many predictors relative to the number of observations.

4. Selecting the optimal \lambda:

Selecting the correct lambda value is crucial. Cross-validation techniques are often employed to find the optimal value, balancing model complexity and predictive performance.

The primary objective of Lasso regression is to minimize the residual sum of squares (RSS) along with a penalty term multiplied by the sum of the absolute values of the coefficients.

bias-varianec-trade-off-copy
Graphical Representation of Lasso Regression

In the plot, the equation for the Lasso Regression of cost function combines the residual sum of squares (RSS) and an L1 penalty on the coefficients β_j.

  • RSS measures: The squared difference between the expected and actual values is measured.
  • L1 penalty: Penalizes the coefficients' absolute values, bringing some of them to zero and simplifying the model. The L1 penalty's strength is managed via the lambda term. Stronger penalties result from greater lambdas which may both increase the RSS and make the model having more coefficients equal to zero.
  • y-axis: represents the value of the cost function which Lasso Regression tries to minimize.
  • x-axis: represents the value of the lambda (λ) parameter which controls the strength of the L1 penalty in the cost function.
  • Green to orange curve: This curve depicts how the cost function (y-axis) changes with increasing lambda (x-axis). As lambda increases the curve transitions from green to orange. This represents the cost function value going up as the L1 penalty becomes stronger forcing more coefficients to zero.

When to use Lasso Regression

Lasso Regression is particularly useful in the following situations:

  • Feature Selection: It automatically selects the most important features by reducing the coefficients of less significant features to zero.
  • Collinearity: When there is multicollinearity, it can help us by reducing the coefficients of correlated variables and selecting only one of them.
  • Regularization: It helps preventing overfitting by penalizing large coefficients which is especially useful when the number of predictors is large.
  • Interpretability: Compared to conventional linear regression models that incorporate all features, lasso regression generates a sparse models with fewer non-zero coefficients making model simpler to understand.

For its implementation you can refer to:

Advantages of Lasso Regression

  • Feature Selection: Lasso regression eliminates the need to manually select the most relevant features, hence, the developed regression model becomes simpler and more explainable.
  • Regularization: Lasso constrains large coefficients, so a less biased model is generated, which is robust and general in its predictions.
  • Interpretability: With lasso, models are often sparsity induced, therefore, they are easier to interpret and explain, which is essential in fields like health care and finance.
  • Handles Large Feature Spaces: Lasso lends itself to dealing with high-dimensional data like we have in genomic as well as imaging studies.

Disadvantages of Lasso Regression

  • Selection Bias: Lasso, might arbitrarily choose one variable in a group of highly correlated variables rather than the other, thereby yielding a biased model in the end.
  • Sensitive to Scale: Lasso is demanding in the respect that features of different orders have a tendency to affect the regularization line and the model's precision.
  • Impact of Outliers: Lasso can be easily affected by the outliers in the given data, resulting into the overfitting of the coefficients.
  • Model Instability: In the environment of multiple correlated variables the lasso's selection of variable may be unstable, which results in different variable subsets each time in tiny data change.
  • Tuning Parameter Selection: Analyzing different λ (alpha) values may be problematic and maybe solved by cross-validation.

By introducing a penalty term to the coefficients, Lasso encourages sparsity, simplifying the model and enhancing its interpretability. Understanding when and how to apply Lasso Regression can significantly improve model accuracy and prevent overfitting.


Next Article

Similar Reads

three90RightbarBannerImg