import numpy as np
import matplotlib.pyplot as plt from sklearn.datasets import load_boston
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.model_selection import cross_val_score X,y = load_boston(return_X_y=True) n_features = X.shape[1] model = GradientBoostingRegressor(n_estimators=50,random_state=1) from skopt.space import Real,Integer,Categorical
from skopt.utils import use_named_args space = [Integer(1,5,name="max_depth"),
Real(10**-5, 10**0, "log-uniform", name='learning_rate'),
Integer(1, n_features, name='max_features'),
Integer(2, 100, name='min_samples_split'),
Integer(1, 100, name='min_samples_leaf')] # this decorator allows your objective function to receive a the parameters as
# keyword arguments. This is particularly convenient when you want to set scikit-learn
@use_named_args(space)
def objective(**params):
model.set_params(**params)
return -np.mean(cross_val_score(model,X,y,cv=5,n_jobs=-1,scoring="neg_mean_absolute_error")) from skopt import gp_minimize
result = gp_minimize(objective,space,n_calls=50,random_state=0) from skopt.plots import plot_convergence
from skopt.plots import plot_evaluations
from skopt.plots import plot_objective plot_convergence(result)
plot_evaluations(result)
plot_objective(result) plt.show()

最新文章

  1. TKT中文编程语言简介
  2. Mybatis获取插入记录的自增长ID(转)
  3. linux的“自动化”
  4. JAVA内嵌数据库H2的使用入门
  5. extjs5 常用属性的说明
  6. NFC基础
  7. 【转】AngularJS 取消对 HTML 片段的转义
  8. 使用STL离散化
  9. 无限互联IOS电影项目视频笔记
  10. Struts2笔记——自定义拦截器
  11. linux环境c++开发:ubuntu12.04使用llvm3.4.2
  12. IOS SWIFT 简单操作文件
  13. MongoDB聚合管道(Aggregation Pipeline)
  14. ZEN_CART_如何添加自定义页面
  15. Html常用标签元素
  16. 栈和队列的java简单实现
  17. shell脚本格式的几点注意:格式严格,空格不能随便出现(一写就记不住)
  18. Codeforces.24D.Broken robot(期望DP 高斯消元)
  19. 50个常用sql语句 网上流行的学生选课表的例子
  20. html 列表 ol 、ul 、dl

热门文章

  1. WebGL编程指南案例解析之加载纹理(贴图)
  2. promise的生命周期
  3. runtime error (运行时错误)
  4. centos7系统初始化
  5. Spring AOP体系学习总结
  6. 【opencv基础】detectMultiScale-output detection score
  7. VM中 Ubuntu14.04 中Samba的安装配置和使用
  8. Codeforces Round #462 (Div. 2) B-A Prosperous Lot
  9. django 远程数据库mysql migrate失败报error 1045之 解决方案
  10. 【spring data jpa】好文储备