#调参通过网格搜索完成
from sklearn.datasets import make_hastie_10_2
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import make_scorer
from sklearn.metrics import recall_score,r2_score
from sklearn.ensemble import GradientBoostingRegressor
X=data[feature].values
y=data['Label'].values
# The scorers can be either be one of the predefined metric strings or a scorer
# callable, like the one returned by make_scorer
scoring = {'Mse': make_scorer(mean_squared_error), 'r2': make_scorer(r2_score)}
# Setting refit='AUC', refits an estimator on the whole dataset with the
# parameter setting that has the best cross-validated AUC score.
# That estimator is made available at ``gs.best_estimator_`` along with
# parameters like ``gs.best_score_``, ``gs.best_params_`` and
# ``gs.best_index_``
gs = GridSearchCV(GradientBoostingRegressor(random_state=42),
param_grid={'min_samples_split': range(10, 100, 5)},
scoring=scoring, cv=5, refit='r2', return_train_score=True)
gs.fit(X, y)
results = gs.cv_results_