Sklearn LassoCV - Training a Lasso Regression Model With Cross Validation
Python
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 2| 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| model.fit(X_train, y_train)
150
133
128
120