常用参数优化方法过程分析

参数网格搜索过程

param_search(DATA,x_range,y_range,x_step,y_step)

# 网格化参数组合-以二维参数为例
# 每个参数的设置范围和步长可调整

# DATA - 数据集

params = []  # 初始化参数空间
for x in x_range:  # 参数1取样
    for y in y_range:  # 参数2取样
        params.append([x, y]])  # 送入参数表-注意步长

score = []  # 初始化评分结果
for param in params:  # 遍历参数表
    score = model(DATA, param)  # 计算评分
score_ranking = sorted(score)  # 评分排序

best_score = score_ranking[0]  # 抽取最优评分
best_param = params[best_score_NO]  # 最优评分对应的参数

自动精细化搜索

auto_param_search(DATA,x_range,y_range,x_step,y_step)

old_step = 10  # 原粗略网格搜索步长
new_step = 1  # 新精细网格搜索步长
new_step_num = 10  # 更新的参数采样数目

x_step, y_step = old_step, old_step  # 为便于并行计算进行相同赋值

# 1 - 粗筛参数
best_param_x, best_param_y = 
param_search(DATA,x_range,y_range,x_step,y_step)

# 更新后的参数网格
x_new_range = 
get_range(best_param_x - old_step, best_param_x + old_step, 
new_step_num)
y_new_range = 
get_range(best_param_y - old_step, best_param_x + old_step, 
new_step_num)

# 2 - 精筛参数
x_step, y_step = new_step, new_step
best_param_new = 
param_search(DATA,x_range,y_range,x_step,y_step)

# 注 - 也可叠加网格缩放比例来达到多重缩放效果

加速参数计算

accelerate_param_search(DATA,x_range,y_range,x_step,y_step)

# 注-此方法暂时只适用于类似正态分布的优化曲面

# x_range - 人工初筛后的参数1取样空间
# y_range - 人工初筛后的参数2取样空间
# step_fast - 快速移动步长
# step_low - 慢速移动步长

# 初始化评分结果
score_old = 0  
score_new = 1 
for x in x_iter_times:  # 参数1迭代次数
    for y in y_iter_times:  # 参数2迭代次数
        if score_new > score_old:
            x = x_range_min + step
            y = y_range_min + step
            score_new = model(DATA, x, y)  # 计算评分
        if score_new < score_old:
            step = step/2
            x = x_range_min - step
            y = y_range_min - step
            score_new = model(DATA, x, y)  # 计算评分
        if abs(score_new - score_old) < 1e2:
            break

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值