小编Bio*_*wav的帖子

我的贝叶斯优化自定义距离在 scipy.spatial.distance.cdist 函数中运行非常慢

您好,我正在尝试使用 bayesian_optimization和自定义内核函数(具体来说是使用 kendall 距离的RBF版本)来执行贝叶斯优化。

我试图将kendall distance作为参数传递给位于 scipy.spatial.distance 中的cdistpdist函数。我正在重用scipy.stats.kendalltau中的 kendalltau 函数的代码,具体来说,我的 kendall 距离定义如下:

def kendall_distance(x,y):
    perm = np.argsort(y)  # sort on y and convert y to dense ranks
    x, y = x[perm], y[perm]
    y = np.r_[True, y[1:] != y[:-1]].cumsum(dtype=np.intp)

    # stable sort on x and convert x to dense ranks
    perm = np.argsort(x, kind='mergesort')
    x, y = x[perm], y[perm]
    x = np.r_[True, x[1:] != x[:-1]].cumsum(dtype=np.intp)

    dis = _kendall_dis(x, y)  # discordant …
Run Code Online (Sandbox Code Playgroud)

python optimization performance numpy scipy

5
推荐指数
0
解决办法
374
查看次数

标签 统计

numpy ×1

optimization ×1

performance ×1

python ×1

scipy ×1