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()

skopt超参数优化实例的更多相关文章

  1. 机器学习超参数优化算法-Hyperband

    参考文献:Hyperband: Bandit-Based Configuration Evaluation for Hyperparameter Optimization I. 传统优化算法 机器学习 ...

  2. CNN超参数优化和可视化技巧详解

    https://zhuanlan.zhihu.com/p/27905191 在深度学习中,有许多不同的深度网络结构,包括卷积神经网络(CNN或convnet).长短期记忆网络(LSTM)和生成对抗网络 ...

  3. lecture16-联合模型、分层坐标系、超参数优化及本课未来的探讨

    这是HInton的第16课,也是最后一课. 一.学习一个图像和标题的联合模型 在这部分,会介绍一些最近的在学习标题和描述图片的特征向量的联合模型上面的工作.在之前的lecture中,介绍了如何从图像中 ...

  4. sklearn参数优化方法

    学习器模型中一般有两个参数:一类参数可以从数据中学习估计得到,还有一类参数无法从数据中估计,只能靠人的经验进行指定,后一类参数就叫超参数 比如,支持向量机里的C,Kernel,gama,朴素贝叶斯里的 ...

  5. 《转》sklearn参数优化方法

    sklearn参数优化方法  http://www.cnblogs.com/nolonely/p/7007961.html   学习器模型中一般有两个参数:一类参数可以从数据中学习估计得到,还有一类参 ...

  6. sklearn参数优化

    学习器模型中一般有两个参数:一类参数可以从数据中学习估计得到,还有一类参数无法从数据中估计,只能靠人的经验进行指定,后一类参数就叫超参数 比如,支持向量机里的C,Kernel,gama,朴素贝叶斯里的 ...

  7. 积神经网络(CNN)的参数优化方法

    http://www.cnblogs.com/bonelee/p/8528863.html 积神经网络的参数优化方法——调整网络结构是关键!!!你只需不停增加层,直到测试误差不再减少. 积神经网络(C ...

  8. TensorFlow从0到1之TensorFlow超参数及其调整(24)

    正如你目前所看到的,神经网络的性能非常依赖超参数.因此,了解这些参数如何影响网络变得至关重要. 常见的超参数是学习率.正则化器.正则化系数.隐藏层的维数.初始权重值,甚至选择什么样的优化器优化权重和偏 ...

  9. TensorFlow实现超参数调整

    TensorFlow实现超参数调整 正如你目前所看到的,神经网络的性能非常依赖超参数.因此,了解这些参数如何影响网络变得至关重要. 常见的超参数是学习率.正则化器.正则化系数.隐藏层的维数.初始权重值 ...

随机推荐

  1. jquery日期和时间的插件精确到秒

    首先.html5提供了input的time类型,使我们可以通过input框输入日期,但是如果我们的需求是这个时间需要明确到几时几分几秒的,那html5就没有办法满足我们的需求了,就需要使用jQuery ...

  2. 接口测试之postman-简单使用

    Postman功能(https://www.getpostman.com/features) 主要用于模拟网络请求包 快速创建请求 回放.管理请求 快速设置网络代理 安装 下载地址:https://w ...

  3. win+linux双系统安装笔记

    1.出现win与linux只能引导之一启动,此时启动linux并更改启动文件可以用linux自带的grub2引导启动 2.ubuntu64位安装时需要联网,因为其有bug,镜像文件中缺少gurb2,需 ...

  4. opencv-python教程学习系列13-图像平滑

    前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍图像平滑,坚持学习,共同进步. 系列教程参照OpenCV-Python中文教程: 系统环境 系统: ...

  5. 51Nod 1091:线段的重叠(贪心)

    1091 线段的重叠  基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题  收藏  关注 X轴上有N条线段,每条线段包括1个起点和终点.线段的重叠是这样来算的,[10 ...

  6. Sublime Text3 使用

    注: 1.绿色版的某些插件有问题,导致某些插件无法使用,而且无法删除和安装,需要删除Data/Cache目录,重新安装无法使用的插件 2.绿色版无法编译python,可使用安装版安装sublime后, ...

  7. hello1与hello2在glassfish上部署

    部署hello1 打开项目实例 找到hello1(tutorial-examples-master\web\jsf\hello1) 并在当前目录打开cmd并输入mvn install命令在hello1 ...

  8. Microsoft - Find the K closest points to the origin in a 2D plane

    Find the K closest points to the origin in a 2D plane, given an array containing N points. 用 max hea ...

  9. web.xml中context-param详解

    <context-param> <param-name>contextConfigLocation</param-name> <param-value> ...

  10. C语言面试题4

    第二部分:程序代码评价或者找错 1.下面的代码输出是什么,为什么?void foo(void){    unsigned int a = 6;    int b = -20;    (a+b > ...