we increase the default setting of "max_iter"otherwise the model would warn us that we should increase max_iter lasso lasso(alpha= max_iter= fit(x_trainy_trainprint("training set score{ }format(lasso score(x_trainy_train))print("test set score{ }format(lasso score(x_testy_test))print("number of features used{}format(np sum(lasso coef_ ! ))out[ ]training set score test set score number of features used lower alpha allowed us to fit more complex modelwhich worked better on the training and test data the performance is slightly better than using ridgeand we are using only of the features this makes this model potentially easier to understand if we set alpha too lowhoweverwe again remove the effect of regularization and end up overfittingwith result similar to linearregressionin[ ]lasso lasso(alpha= max_iter= fit(x_trainy_trainprint("training set score{ }format(lasso score(x_trainy_train))print("test set score{ }format(lasso score(x_testy_test))print("number of features used{}format(np sum(lasso coef_ ! ))out[ ]training set score test set score number of features used againwe can plot the coefficients of the different modelssimilarly to figure - the result is shown in figure - in[ ]plt plot(lasso coef_' 'label="lasso alpha= "plt plot(lasso coef_'^'label="lasso alpha= "plt plot(lasso coef_' 'label="lasso alpha= "plt plot(ridge coef_' 'label="ridge alpha= "plt legend(ncol= loc=( )plt ylim(- plt xlabel("coefficient index"plt ylabel("coefficient magnitude" supervised learning