tune_hyperparms_regression.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Gaussian_process 作者: happyjin 项目源码 文件源码
def PI(params, means, stand_devi, parms_done, y, n_iterations, k):
    """
    Probability of Improvement acquisition function
    :param params: test data
    :param means: GP posterior mean
    :param stand_devi: standard deviation
    :param parms_done: training data
    :param y: training targets
    :return: next point that need to pick up
    """
    s = 0.0005  # small value
    stop_threshold = 0.001
    max_mean = np.max(y)

    f_max = max_mean + s
    z = (means - f_max) / stand_devi
    cumu_gaussian = norm.cdf(z)
    # early stop criterion, if there are less than 1% to get the greater cumulative Gaussian, then stop.
    if cumu_gaussian.sum() <= stop_threshold or np.max(cumu_gaussian) <= stop_threshold:
        print "all elements of cumulative are alost zeros!!!"
        return True
    indices = np.where(cumu_gaussian == np.max(cumu_gaussian))[0]
    indices = np.asarray(indices)
    # since there are several 1, random pick one of them as the next point except for parms_done
    rand_index = random.randint(0, len(indices) - 1)
    next_point = params[indices[rand_index]]
    condition = next_point in parms_done.tolist()
    # early stop criterion, if there is no other point that can maximize the objective then stop
    while condition:
        rand_index = random.randint(0, len(indices) - 1)
        next_point = params[indices[rand_index]]
        condition = next_point in parms_done.tolist()
        if len(next_point) == 1 and condition:
            return True

    if k == n_iterations-1:
        plt.subplot(2, 1, 2)
        plt.plot(params, cumu_gaussian, label='PI')
    return next_point
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号