def model_gradient_boosting_tree(Xtrain,Xtest,ytrain):
X_train = Xtrain
y_train = ytrain
gbr = GradientBoostingRegressor(random_state=0)
param_grid = {
'n_estimators': [800,1500],
'max_features': [20,15],
'max_depth': [8,10],
'learning_rate': [0.1],
'subsample': [1]
}
model = GridSearchCV(estimator=gbr, param_grid=param_grid, n_jobs=1, cv=10, scoring=RMSE)
model.fit(X_train, y_train)
print('Gradient boosted tree regression...')
print('Best Params:')
print(model.best_params_)
print('Best CV Score:')
print(-model.best_score_)
y_pred = model.predict(Xtest)
return y_pred, -model.best_score_
# read data, build model and do prediction
gradient_boosting.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录