Least Angle Regression (LARS) (original) (raw)

Last Updated : 15 Jul, 2025

Regression is a supervised machine learning task that can predict continuous values (real numbers), as compared to classification, that can predict categorical or discrete values. Before we begin, if you are a beginner, I highly recommend this article.
Least Angle Regression (LARS) is an algorithm used in regression for high dimensional data (i.e., data with a large number of attributes). Least Angle Regression is somewhat similar to forward stepwise regression. Since it is used with data that has lots of attributes, at each step, LARS finds the attribute which is most highly correlated to the target value. There may be more than one attribute that has the same correlation. In this scenario, LARS averages the attributes and proceeds in a direction that is at the same angle to the attributes. This is exactly why this algorithm is called Least Angle regression. Basically, LARS makes leaps in the most optimally calculated direction without overfitting the model.
Algorithm:

Note : Residual is the difference between the observed value and the predicted value. Variable, here implies an attribute.

Mathematically, LARS works as follows :

Implementation of LARS in Python3:
For this example, we will be using the Boston housing dataset that has the median value of homes in the Boston Massachusetts area. You can learn more about this dataset here.
For evaluation, we will be using the r2 score. The best possible r2 score is 1.0. It can also be negative and is 0, when the predictor always predicts a constant value, regardless of values of attributes.
Code:

python3 `

Importing modules that are required

from sklearn.datasets import load_boston from sklearn.linear_model import LassoLars from sklearn.metrics import r2_score from sklearn.model_selection import train_test_split

Loading dataset

dataset = load_boston() X = dataset.data y = dataset.target

Splitting training and testing data

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.15, random_state = 42)

Creating and fitting the regressor

regressor = LassoLars(alpha = 0.1) regressor.fit(X_train, y_train)

Evaluating model

prediction = regressor.predict(X_test)

print(f"r2 Score of test set : {r2_score(y_test, prediction)}")

`

Output:

r2 Score of test set : 0.6815908068381828

We have achieved an r2 score of approximately 0.6816, which is actually quite good.
Advantages of using LARS:

Disadvantages of using LARS:

Reference: