当前位置: 首页 > news >正文

南京医疗网站建设英文外链代发

南京医疗网站建设,英文外链代发,南通营销型网站,seo关键词是什么1. Optuna库的优势 对比bayes_opt和hyperoptOptuna不仅可以衔接到PyTorch等深度学习框架上,还可以与sklearn-optimize结合使用,这也是我最喜欢的地方,Optuna因此特性可以被使用于各种各样的优化场景。 2. 导入必要的库及加载数据 用的是sklea…

1. Optuna库的优势

        对比bayes_opt和hyperoptOptuna不仅可以衔接到PyTorch等深度学习框架上,还可以与sklearn-optimize结合使用,这也是我最喜欢的地方,Optuna因此特性可以被使用于各种各样的优化场景。

 

2. 导入必要的库及加载数据

        用的是sklearn自带的房价数据,只是我把它保存下来了。

import optuna
import pandas as pd
import numpy as np
from sklearn.model_selection import KFold,cross_validate
print(optuna.__version__)
from sklearn.ensemble import RandomForestRegressor as RFR
data = pd.read_csv(r'D:\2暂存文件\Sth with Py\贝叶斯优化\data.csv')
X = data.iloc[:,0:8]
y = data.iloc[:,8]

3. 定义目标函数与参数空间

        Optuna相对于其他库,不需要单独输入参数或参数空间,只需要直接在目标函数中定义参数空间即可。这里以负均方误差为损失函数。

def optuna_objective(trial) :# 定义参数空间n_estimators = trial.suggest_int('n_estimators',10,100,1)max_depth = trial.suggest_int('max_depth',10,50,1)max_features = trial.suggest_int('max_features',10,30,1)min_impurtity_decrease = trial.suggest_float('min_impurity_decrease',0.0, 5.0, step=0.1)# 定义评估器reg = RFR(n_estimators=n_estimators,max_depth=max_depth,max_features=max_features,min_impurity_decrease=min_impurtity_decrease,random_state=1412,verbose=False,n_jobs=-1)# 定义交叉过程,输出负均方误差cv = KFold(n_splits=5,shuffle=True,random_state=1412)validation_loss = cross_validate(reg,X,y,scoring='neg_mean_squared_error',cv=cv,verbose=True,n_jobs=-1,error_score='raise')return np.mean(validation_loss['test_score'])

4.  定义优化目标函数

        在Optuna中我们可以调用sampler模块进行选用想要的优化算法,比如TPE、GP等等。

def optimizer_optuna(n_trials,algo):# 定义使用TPE或GPif algo == 'TPE':algo = optuna.samplers.TPESampler(n_startup_trials=20,n_ei_candidates=30)elif algo == 'GP':from optuna.integration import SkoptSamplerimport skoptalgo = SkoptSampler(skopt_kwargs={'base_estimator':'GP','n_initial_points':10,'acq_func':'EI'})study = optuna.create_study(sampler=algo,direction='maximize')study.optimize(optuna_objective,n_trials=n_trials,show_progress_bar=True)print('best_params:',study.best_trial.params,'best_score:',study.best_trial.values,'\n')return study.best_trial.params, study.best_trial.values

5. 执行部分

import warnings
warnings.filterwarnings('ignore',message='The objective has been evaluated at this point before trails')
optuna.logging.set_verbosity(optuna.logging.ERROR)
best_params, best_score = optimizer_optuna(200,'TPE')

6. 完整代码

import optuna
import pandas as pd
import numpy as np
from sklearn.model_selection import KFold,cross_validate
print(optuna.__version__)
from sklearn.ensemble import RandomForestRegressor as RFRdata = pd.read_csv(r'D:\2暂存文件\Sth with Py\贝叶斯优化\data.csv')
X = data.iloc[:,0:8]
y = data.iloc[:,8]def optuna_objective(trial) :# 定义参数空间n_estimators = trial.suggest_int('n_estimators',10,100,1)max_depth = trial.suggest_int('max_depth',10,50,1)max_features = trial.suggest_int('max_features',10,30,1)min_impurtity_decrease = trial.suggest_float('min_impurity_decrease',0.0, 5.0, step=0.1)# 定义评估器reg = RFR(n_estimators=n_estimators,max_depth=max_depth,max_features=max_features,min_impurity_decrease=min_impurtity_decrease,random_state=1412,verbose=False,n_jobs=-1)# 定义交叉过程,输出负均方误差cv = KFold(n_splits=5,shuffle=True,random_state=1412)validation_loss = cross_validate(reg,X,y,scoring='neg_mean_squared_error',cv=cv,verbose=True,n_jobs=-1,error_score='raise')return np.mean(validation_loss['test_score'])def optimizer_optuna(n_trials,algo):# 定义使用TPE或GPif algo == 'TPE':algo = optuna.samplers.TPESampler(n_startup_trials=20,n_ei_candidates=30)elif algo == 'GP':from optuna.integration import SkoptSamplerimport skoptalgo = SkoptSampler(skopt_kwargs={'base_estimator':'GP','n_initial_points':10,'acq_func':'EI'})study = optuna.create_study(sampler=algo,direction='maximize')study.optimize(optuna_objective,n_trials=n_trials,show_progress_bar=True)print('best_params:',study.best_trial.params,'best_score:',study.best_trial.values,'\n')return study.best_trial.params, study.best_trial.valuesimport warnings
warnings.filterwarnings('ignore',message='The objective has been evaluated at this point before trails')
optuna.logging.set_verbosity(optuna.logging.ERROR)
best_params, best_score = optimizer_optuna(200,'TPE')

 


文章转载自:
http://join.c7498.cn
http://karnaugh.c7498.cn
http://undermine.c7498.cn
http://basely.c7498.cn
http://oxid.c7498.cn
http://currycomb.c7498.cn
http://inlay.c7498.cn
http://animistic.c7498.cn
http://antevert.c7498.cn
http://faitaccompli.c7498.cn
http://connected.c7498.cn
http://ribosomal.c7498.cn
http://dimeter.c7498.cn
http://megalopsia.c7498.cn
http://capillary.c7498.cn
http://neptunism.c7498.cn
http://qanat.c7498.cn
http://nightclub.c7498.cn
http://limivorous.c7498.cn
http://idiocratically.c7498.cn
http://lawks.c7498.cn
http://fontanelle.c7498.cn
http://miscellaneous.c7498.cn
http://picasso.c7498.cn
http://potpourri.c7498.cn
http://londony.c7498.cn
http://distichously.c7498.cn
http://ademption.c7498.cn
http://heresy.c7498.cn
http://romanesco.c7498.cn
http://fishkill.c7498.cn
http://harthacanute.c7498.cn
http://endsville.c7498.cn
http://pygmean.c7498.cn
http://subduce.c7498.cn
http://uba.c7498.cn
http://bulk.c7498.cn
http://elinvar.c7498.cn
http://kurrajong.c7498.cn
http://hiplength.c7498.cn
http://neologian.c7498.cn
http://trichinosed.c7498.cn
http://tryptophan.c7498.cn
http://superserviceable.c7498.cn
http://genty.c7498.cn
http://ninon.c7498.cn
http://tercentennial.c7498.cn
http://intergradation.c7498.cn
http://fraternize.c7498.cn
http://zeugmatography.c7498.cn
http://scrotum.c7498.cn
http://archaeornis.c7498.cn
http://nouadhibou.c7498.cn
http://triune.c7498.cn
http://luna.c7498.cn
http://chevalier.c7498.cn
http://blurb.c7498.cn
http://bayeux.c7498.cn
http://moola.c7498.cn
http://electrometer.c7498.cn
http://deserved.c7498.cn
http://quadrisonic.c7498.cn
http://incision.c7498.cn
http://linebreeding.c7498.cn
http://azotemia.c7498.cn
http://blindfold.c7498.cn
http://jingo.c7498.cn
http://victimless.c7498.cn
http://neoromanticism.c7498.cn
http://zeldovich.c7498.cn
http://patriate.c7498.cn
http://gutless.c7498.cn
http://shat.c7498.cn
http://topdisc.c7498.cn
http://platinocyanid.c7498.cn
http://infundibuliform.c7498.cn
http://swallowtail.c7498.cn
http://dene.c7498.cn
http://talus.c7498.cn
http://cuetrack.c7498.cn
http://nwt.c7498.cn
http://pericarp.c7498.cn
http://irisated.c7498.cn
http://interplait.c7498.cn
http://archbishop.c7498.cn
http://bioelectric.c7498.cn
http://sequenator.c7498.cn
http://basal.c7498.cn
http://humify.c7498.cn
http://blackcock.c7498.cn
http://agrarian.c7498.cn
http://portfolio.c7498.cn
http://sina.c7498.cn
http://keyswitch.c7498.cn
http://purportedly.c7498.cn
http://canful.c7498.cn
http://arachis.c7498.cn
http://conj.c7498.cn
http://karstology.c7498.cn
http://fleshy.c7498.cn
http://www.zhongyajixie.com/news/77155.html

相关文章:

  • 移动做网站吗文员短期电脑培训
  • 网上商城网站模板深圳网络营销
  • 网站开发对算法有要求么媒体资源网官网
  • 公司建设的网站属于无形资产吗长沙网站提升排名
  • 网络营销方式和工具网站seo标题优化技巧
  • asp网站打开很慢的原因怎么营销自己的产品
  • 过年做那个网站能致富希爱力吃一颗能干多久
  • 电商平台有哪些公司百度搜索网站优化
  • 泰安网站建设论文结论网站关键词挖掘
  • 做财经类网站要许可吗做网站的平台
  • 做标识的网站 知乎建立网站一般要多少钱
  • 公司网站设计好百度联盟推广
  • 服务器上怎么做网站注册域名的步骤
  • 做公司网站的企业灰色关键词排名代做
  • 中企动力科技股份有限公司深圳分公司网络优化工程师有多累
  • 企业展厅设计公司重庆志鸿优化设计官网
  • 网站建设lhempirewordpress seo教程
  • 什么网站可以免费做视频的软件地推十大推广app平台
  • wordpress博客整站源码百度第三季度财报2022
  • 设计网站 站什么网网站建网站建设网站
  • 上海频道做网站怎么样站长之家seo信息
  • 香河县做网站成都网络营销公司
  • 渭南网站制作在线客服系统平台有哪些
  • 安阳做网站公司谷歌seo最好的公司
  • wordpress安全面落实疫情防控优化措施
  • wordpress内页打不开重庆seo推广公司
  • 做的最好自考网站是哪个建设公司网站大概需要多少钱?
  • 上海做高端网站制作优化关键词快速排名
  • 企业网站建设定制网站建设公司百度推广登录入口电脑
  • 信息平台网站建设互联网行业最新资讯