Sklearn LassoCV - Training a Lasso Regression Model With Cross Validation


In this example we'll train a regression model using LassoCV. This fits a Lasso regression model but tunes the alpha parameter using cross validation.

 1|  from sklearn.linear_model import LassoCV
 3|  # initialise & fit a Lasso regression model with alpha set to None
 4|  # so that alphas are passed automatically. Alternativly a list of 
 5|  # alpha values can be specified 
 6|  model = LassoCV(alphas=None,
 7|                 n_jobs=-1,
 8|                 cv=5)
 9|, y_train)
Did you find this snippet useful?

Sign up for free to to add this to your code library