<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 EstimatorCV Objects for Efficient Parameter Search
Recursive Feature Eliminiation
Step1:  Efficient hyper-parameter selection for Lasso
<ASSISTANT_TASK:>
Python Code:
from sklearn.datasets import load_iris
from sklearn.cross_validation import train_test_split
iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, random_state=0)
from sklearn.feature_selection import RFE
from sklearn.linear_model import LogisticRegression
feature_elimination_lr = RFE(LogisticRegression(C=100), n_features_to_select=2)
feature_elimination_lr.fit(X_train, y_train)
feature_elimination_lr.score(X_test, y_test)
from sklearn.grid_search import GridSearchCV
param_grid = {'n_features_to_select': range(1, 5)}
grid_search = GridSearchCV(feature_elimination_lr, param_grid, cv=5)
grid_search.fit(X_train, y_train)
grid_search.score(X_test, y_test)
grid_search.best_params_
from sklearn.feature_selection import RFECV
rfecv = RFECV(LogisticRegression(C=100)).fit(X_train, y_train)
rfecv.score(X_test, y_test)
rfecv.n_features_
Explanation: EstimatorCV Objects for Efficient Parameter Search
Recursive Feature Eliminiation
End of explanation
from sklearn.datasets import make_regression
X, y = make_regression(noise=60, random_state=0)
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0)
from sklearn.linear_model import Lasso, LassoCV
lasso = Lasso().fit(X_train, y_train)
print("lasso score with default alpha: %f" % lasso.score(X_test, y_test))
lassocv =  LassoCV().fit(X_train, y_train)
print("lasso score with automatic alpha: %f" % lassocv.score(X_test, y_test))
grid_search = GridSearchCV(Lasso(), param_grid={'alpha': np.logspace(-5, 1, 20)})
grid_search.fit(X_train, y_train)
print("lasso score with grid-searched alpha: %f" % grid_search.score(X_test, y_test))
print("best alpha found by LassoCV: %f" % lassocv.alpha_)
print("best alpha found by GridSearchCV: %f" % grid_search.best_params_['alpha'])
%timeit Lasso().fit(X_train, y_train)
%timeit LassoCV().fit(X_train, y_train)
%timeit grid_search.fit(X_train, y_train)
Explanation: Efficient hyper-parameter selection for Lasso
End of explanation
<END_TASK>