skopt超参数优化实例
2024-08-27 16:33:52
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()
最新文章
- TKT中文编程语言简介
- Mybatis获取插入记录的自增长ID(转)
- linux的“自动化”
- JAVA内嵌数据库H2的使用入门
- extjs5 常用属性的说明
- NFC基础
- 【转】AngularJS 取消对 HTML 片段的转义
- 使用STL离散化
- 无限互联IOS电影项目视频笔记
- Struts2笔记——自定义拦截器
- linux环境c++开发:ubuntu12.04使用llvm3.4.2
- IOS SWIFT 简单操作文件
- MongoDB聚合管道(Aggregation Pipeline)
- ZEN_CART_如何添加自定义页面
- Html常用标签元素
- 栈和队列的java简单实现
- shell脚本格式的几点注意:格式严格,空格不能随便出现(一写就记不住)
- Codeforces.24D.Broken robot(期望DP 高斯消元)
- 50个常用sql语句 网上流行的学生选课表的例子
- html 列表 ol 、ul 、dl
热门文章
- WebGL编程指南案例解析之加载纹理(贴图)
- promise的生命周期
- runtime error (运行时错误)
- centos7系统初始化
- Spring AOP体系学习总结
- 【opencv基础】detectMultiScale-output detection score
- VM中 Ubuntu14.04 中Samba的安装配置和使用
- Codeforces Round #462 (Div. 2) B-A Prosperous Lot
- django 远程数据库mysql migrate失败报error 1045之 解决方案
- 【spring data jpa】好文储备