python - 在贝叶斯优化包 Python 中迭代整数

标签 python numpy bayesian

我使用贝叶斯优化包( https://github.com/fmfn/BayesianOptimization )进行参数优化。默认情况下,这个库迭代浮点数,但我不迭代整数,我该如何执行?

def black_box_function(x, y):
    return -x ** 2 - (y - 1) ** 2 + 1
from bayes_opt import BayesianOptimization
pbounds = {'x': (2, 4), 'y': (-3, 3)}

optimizer = BayesianOptimization(
    f=black_box_function,
    pbounds=pbounds,
    verbose=2, 
    random_state=1,
)

optimizer.maximize(
    init_points=2,
    n_iter=3,
)
# and as you can see it is iterated not over integers.
|   iter    |  target   |     x     |     y     |
-------------------------------------------------
|  1        | -7.135    |  2.834    |  1.322    |
|  2        | -7.78     |  2.0      | -1.186    |
|  3        | -19.0     |  4.0      |  3.0      |
|  4        | -16.3     |  2.378    | -2.413    |
|  5        | -4.441    |  2.105    | -0.005822 |
=================================================

最佳答案

您可以阅读 advanced tour 的第 2 部分为了这。

关于python - 在贝叶斯优化包 Python 中迭代整数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57182358/

相关文章:

python - 如何改变NLTK中朴素贝叶斯分类器的平滑方法?

python - Matplotlib:如何为等高线图调整颜色条中的线宽?

python - Discord.py Bot - 如何提及随机用户

python - 在 python 中指定日期时间所在的时区

python - PyStan API 中的变分推理?

bayesian - 如何在pymc中设置确定性变量的键

python - 如何使我的 Python `set` 和 `frozenset` 子类在进行二进制运算时保留其类型?

python - 绘制两个数组的最小值

python - 将两个NumPy数组分组为列表的字典

numpy.savetxt 在 python 3.5 中导致格式不匹配错误