Session Ready
Exercise

Lasso model results

Now that you've trained the Lasso model, you'll score its predictive capacity (\(R^2\)) on the test set and count how many features are ignored because their coefficient is reduced to zero.

The X_test and y_test datasets have been pre-loaded for you.

The Lasso() model and StandardScaler() have been instantiated as la and scaler respectively and both were fitted to the training data.

Instructions
100 XP
  • Transform the test set with the pre-fitted scaler.
  • Calculate the \(R^2\) value on the scaled test data.
  • Create a list that has True values when coefficients equal 0.
  • Calculate the total number of features with a coefficient of 0.