代码之家  ›  专栏  ›  技术社区  ›  Hagbard

距离矩阵快,距离函数慢

  •  1
  • Hagbard  · 技术社区  · 8 年前

    我正在使用Python包 dtaidistance 用于快速DTW计算。如文档中所述,可以使用以下代码:

    from dtaidistance import dtw
    import numpy as np
    series = np.matrix([
        [0.0, 0, 1, 2, 1, 0, 1, 0, 0],
        [0.0, 1, 2, 0, 0, 0, 0, 0, 0],
        [0.0, 0, 1, 2, 1, 0, 0, 0, 0]])
    ds = dtw.distance_matrix_fast(series)
    

    计算系列集合之间的DTW距离度量。我正在处理的时间序列的长度是3000。总的来说,我的每个数据集大约有3500个这样的系列。

    source code )是真的。

    1 回复  |  直到 8 年前
        1
  •  1
  •   Hagbard    7 年前

    结果证明,我只是没有从源代码构建包,因此无法访问更快的基于C的实现。

    提到的步骤 here

    来源。

    Download the source from https://github.com/wannesm/dtaidistance
    Compile the C extensions: python3 setup.py build_ext --inplace
    Install into your site-package directory: python3 setup.py install