dtw-python

5 篇文章 1 订阅

版本:dtw-python 1.3.0

dtw

函数功能:执行 DTW 算法,并计算两个时间序列 x 和 y 之间的最佳匹配(optimal alignment) 。

输入参数
xquery vector 或 local cost matrix
yreference vector。如果 x 是 cost matrix,则 y 不使用。
dist_method

pointwise (local) 距离函数。

若该参数是一个 string:把 x、y 和给定方法一起传给 scipy.spatial.distance.cdist 函数。

若提供一个 n=length(x) 行、m=length(y) 列 的 local-distance matrix:该矩阵的元素 [i,j] 表示 x[i] 和 y[j] 之间的距离。这种方法可以处理多变量时序和其他任意距离矩阵。

step_pattern

一个 stepPattern 对象,用于描述局部限制

该参数支持许多常见的 DTW 变体。

window_type

windowing function。描述全局限制( the envelope of the warping path)。

可以是字符串,表示现有的限制方式:

"none":No windowing (default)

"itakura":Itakura parallelogram

"sakoechiba":A band around main diagonal

"slantedband":A band around slanted diagonal

也可以是一个用户自定义的函数。

更多细节可见 dtwWindowingFunctions()。

window_args传给 windowing function 的额外参数
keep_internals保留 cumulative cost matrix、inputs 以及其他内部结构
distance_only仅计算距离(没有backtrack,速度更快)
open_end实施 open-ended alignments
open_begin实施 open-ended alignments

注:   x 和 y 以数字向量(numeric vector)的形式给出。x 和 y 的长度可以不同。

          最佳匹配 使得 aligned elements 之间的距离和最小。

          不论是输入还是输出,在 代价矩阵(cost matrix)中,query 元素按行排列(first index)、reference 元素按列排列(second index);这些元素的打印习惯为下标向下向右增加(原点在左上角)。

参考文献
Toni Giorgino. Computing and Visualizing Dynamic Time Warping Alignments in R: The dtw Package. Journal of Statistical Software, 31(7), 1-24. http://www.jstatsoft.org/v31/i07/ 
Tormene, P.; Giorgino, T.; Quaglini, S. & Stefanelli, M. Matching incomplete time series with dynamic time warping: an algorithm and an application to post-stroke rehabilitation. Artif Intell Med, 2009, 45, 11-34. http://dx.doi.org/10.1016/j.artmed.2008.11.007 
Sakoe, H.; Chiba, S., Dynamic programming algorithm optimization for spoken word recognition, Acoustics, Speech, and Signal Processing, IEEE Transactions on , vol.26, no.1, pp. 43-49, Feb 1978. http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1163055 
Mori, A.; Uchida, S.; Kurazume, R.; Taniguchi, R.; Hasegawa, T. & Sakoe, H. Early Recognition and Prediction of Gestures Proc. 18th International Conference on Pattern Recognition ICPR 2006, 2006, 3, 560-563
Sakoe, H. Two-level DP-matching–A dynamic programming-based pattern matching algorithm for connected word recognition Acoustics, Speech, and Signal Processing, IEEE Transactions on, 1979, 27, 588-595
Rabiner L, Rosenberg A, Levinson S (1978). Considerations in dynamic time warping algorithms for discrete word recognition. IEEE Trans. Acoust., Speech, Signal Process., 26(6), 575-582. ISSN 0096-3518.
Muller M. Dynamic Time Warping in Information Retrieval for Music and Motion. Springer Berlin Heidelberg; 2007. p. 69-84. http://link.springer.com/chapter/10.1007/978-3-540-74048-3_4 

DTW

 class dtw.DTW(obj。DTW 类 的对象包含了由 dtw() 函数计算的 alignments。

Attributes 属性
distance最小全局距离(没有标准化)
normalizedDistance

若已知 chosen step pattern:根据 path length,对 distance 进行标准化。

Nquery 的长度
Mreference 的长度
callthe function call that created the object(试了一下失败了)
index1x(query) 中 匹配元素的 下标
index2y(reference) 中 被映射的 下标
stepPattern用于计算的 stepPattern 对象
jmin若 open.end=TRUE:reference 中被匹配的最后一个元素
directionMatrix

若 keep.internals=TRUE:在每个 alignment pair 上 step 的方向(用于标记 chosen step pattern 产生规则的整数)

stepsTaken从 alignment 的开始到结束,所走的 steps 的 一个 list(用于标记 chosen step pattern 的 整数)。
index1s

与 index1、index2 一样,

但 排除了 multi-step patterns 中的中间步骤

index2s
costMatrix若 keep.internals=TRUE:cumulative cost matrix
query

若 keep.internals=TRUE 且 作为 x 和 y 参数传递:

query 和 reference 时间序列

reference
Methods 方法
plot绘制 DTW 的结果

dtw.DTW.plot

 plot(type='alignment'**kwargs :将 dtw()函数 返回 的 DTW对象 绘制出来。

输入参数
xdtw object, usually result of call to [dtw()]
ddtw object, usually result of call to [dtw()]
xlabquery 轴的标签
ylabreference 轴的标签
type

图(plot)的总体风格

alignment:plots the warping curve in d

twoway:plots a point-by-point comparison, with matching lines。详见 dtwPlotTwoWay()。

threeway:vis-a-vis inspection of the timeseries and their warping curve。详见 dtwPlotThreeWay()。

density:displays the cumulative cost landscape with the warping path overimposed。详见 dtwPlotDensity()

plot_type图中的线(line)的类型,type 的参数
...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值