Exercise

Lasso regression for feature importance

In the video, you saw how lasso regression can be used to identify important features in a dataset.

In this exercise, you will fit a lasso regression model to the sales_df data and plot the model's coefficients.

The feature and target variable arrays have been pre-loaded as X and y, along with sales_columns, which contains the dataset's feature names.

Instructions

100 XP
  • Import Lasso from sklearn.linear_model.
  • Instantiate a Lasso regressor with an alpha of 0.3.
  • Fit the model to the data.
  • Compute the model's coefficients, storing as lasso_coef.