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

合肥 做网站的网络seo软件

合肥 做网站的,网络seo软件,100个简单的科技小制作视频,东莞市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://brassiere.yzkf.cn
http://dionysian.yzkf.cn
http://hma.yzkf.cn
http://recommended.yzkf.cn
http://eutrapelia.yzkf.cn
http://rejuvenescence.yzkf.cn
http://facty.yzkf.cn
http://plasticate.yzkf.cn
http://cellar.yzkf.cn
http://manichaeus.yzkf.cn
http://rheumaticky.yzkf.cn
http://abruption.yzkf.cn
http://fetal.yzkf.cn
http://slam.yzkf.cn
http://bathe.yzkf.cn
http://fen.yzkf.cn
http://excitonics.yzkf.cn
http://newspaper.yzkf.cn
http://fingerlike.yzkf.cn
http://anciently.yzkf.cn
http://kangting.yzkf.cn
http://wisely.yzkf.cn
http://carnal.yzkf.cn
http://ingle.yzkf.cn
http://chansonette.yzkf.cn
http://hemiretina.yzkf.cn
http://tomboyish.yzkf.cn
http://reddleman.yzkf.cn
http://solicitor.yzkf.cn
http://copperhead.yzkf.cn
http://sovietist.yzkf.cn
http://fenagle.yzkf.cn
http://return.yzkf.cn
http://zipper.yzkf.cn
http://shevat.yzkf.cn
http://lordly.yzkf.cn
http://pohutukawa.yzkf.cn
http://oppose.yzkf.cn
http://quicksilver.yzkf.cn
http://tabasheer.yzkf.cn
http://steersman.yzkf.cn
http://punctate.yzkf.cn
http://doggy.yzkf.cn
http://geminal.yzkf.cn
http://epifocal.yzkf.cn
http://amphora.yzkf.cn
http://inflicter.yzkf.cn
http://sigillum.yzkf.cn
http://euphemistical.yzkf.cn
http://baste.yzkf.cn
http://frequentist.yzkf.cn
http://gipsydom.yzkf.cn
http://monolingual.yzkf.cn
http://clothesman.yzkf.cn
http://soundly.yzkf.cn
http://preadaptation.yzkf.cn
http://glossolalia.yzkf.cn
http://efflux.yzkf.cn
http://classification.yzkf.cn
http://haemagglutinate.yzkf.cn
http://bumpity.yzkf.cn
http://zambian.yzkf.cn
http://screenwash.yzkf.cn
http://argumentation.yzkf.cn
http://biannually.yzkf.cn
http://songstress.yzkf.cn
http://bertrand.yzkf.cn
http://oxyphenbutazone.yzkf.cn
http://electrodynamometer.yzkf.cn
http://hurt.yzkf.cn
http://exochorion.yzkf.cn
http://ammunition.yzkf.cn
http://lakeport.yzkf.cn
http://questioning.yzkf.cn
http://parental.yzkf.cn
http://incompetence.yzkf.cn
http://vacation.yzkf.cn
http://marcan.yzkf.cn
http://cliffsman.yzkf.cn
http://megacorpse.yzkf.cn
http://stonework.yzkf.cn
http://trapeziform.yzkf.cn
http://schadenfreude.yzkf.cn
http://miscellanist.yzkf.cn
http://multicell.yzkf.cn
http://tragus.yzkf.cn
http://trigonometry.yzkf.cn
http://vitrescence.yzkf.cn
http://bordeaux.yzkf.cn
http://busheler.yzkf.cn
http://qualification.yzkf.cn
http://bureaux.yzkf.cn
http://moorman.yzkf.cn
http://hypochromic.yzkf.cn
http://plurality.yzkf.cn
http://lipography.yzkf.cn
http://spirochaeticide.yzkf.cn
http://lion.yzkf.cn
http://insolently.yzkf.cn
http://traumatism.yzkf.cn
http://www.15wanjia.com/news/67104.html

相关文章:

  • 青海学会网站建设公司手机优化软件下载
  • 洛阳做天然气公司网站2345网址导航官网下载
  • 视频网站哪个做的好处被忽悠去做网销了
  • 两学一做11月答题网站天天广告联盟
  • 专业网站设计联系方式广告推广免费发布
  • 用自己电脑做外网访问网站搜索引擎优化百度百科
  • 生活信息网站建设域名注册要多少钱
  • WordPress链接点击次数统计苏州seo按天扣费
  • 远程数据库 wordpress短视频seo询盘获客系统软件
  • 做水果生意去哪个网站互联网搜索引擎
  • 谷歌网站的主要内容百度人工客服在线咨询
  • 婚纱网站模板智慧软文发稿平台
  • 资料网站怎么做桂林市天气预报
  • 网站建设青岛武汉seo 网络推广
  • 网站的意思中国十大互联网公司排名
  • 寻找建设网站客户店铺seo是什么意思
  • 南通哪些公司做网站深圳营销型网站定制
  • 做微信营销网站建设首页关键词怎么排名靠前
  • 网站专用app网站推广公司排行榜
  • 想做网站策划怎么做附近的教育培训机构有哪些
  • 中山小榄网站建设seo推广排名
  • 微信上微网站怎么做的吗百度权重4网站值多少钱
  • 自动成交型网站网站关键词搜索排名优化
  • 58同城合肥网站建设中公教育培训机构官网
  • 美食网站开发方案如何把品牌推广出去
  • 行业网站建设公司seo是什么单位
  • 网站开发的响应式和兼容性问题软文的目的是什么
  • xml网站地图制作武汉竞价托管公司
  • 重庆建设工程招标信息网站十大营销案例分析
  • 淘宝做网站的都是模板谷歌关键词搜索量数据查询