Scikit-Learn + Scipy.在高斯过程回归中优化外部优化器

idv4meu8  于 2023-08-05  发布在  其他
关注(0)|答案(1)|浏览(85)

我第一次使用Scikit-learn的Gaussian Processes回归,我想使用scipy.optimize外部优化器:

gp = GaussianProcessRegressor(kernel=kernel, alpha=0.015, normalize_y=True, optimizer= EXT_OPT).

字符串
使用外部优化库的正确方法是什么?

os8fio9y

os8fio9y1#

事实上我自己发现的。这是很容易的如下:

def optimizer(obj_func, initial_theta, bounds):
    optimResult = scipy.optimize.minimize(obj_func, initial_theta,  method='L-BFGS-B', jac=False)
    theta_opt = optimResult.x0
    func_min = optimResult.fun
    return theta_opt, func_min

字符串

def optimizer(obj_func, initial_theta, bounds):
    theta_opt, func_min, _ = opt.fmin_l_bfgs_b(obj_func, initial_theta, bounds=bounds)
    return theta_opt, func_min
gp = GaussianProcessRegressor(kernel=kernel, alpha=0.015, normalize_y=True, optimizer=optimizer)

的数据

相关问题