Created
July 16, 2020 18:26
-
-
Save Ayushijain09/47874871d18fddcebaebfb57299ccf61 to your computer and use it in GitHub Desktop.
LASSO Regression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.linear_model import Lasso | |
from sklearn.model_selection import GridSearchCV | |
lasso= Lasso() | |
parameters = {'alpha':[1e-15, 1e-10, 1e-8, 1e-4,1e-3,1e-2,1,3,5]} | |
lasso_model = GridSearchCV(lasso, parameters, scoring = 'r2',cv=5) | |
lasso_model.fit(X_train,y_train) | |
pred = lasso_model.predict(X_test) | |
print(lasso_model.best_params_) #output {'alpha': 0.001} | |
print(lasso_model.best_score_) #output 0.8630550401365724 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment