Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
15.358...
>>> unnormalized_gak([1, 2, 3],
... [1., 2., 2., 3., 4.]) # doctest: +ELLIPSIS
3.166...
See Also
--------
gak : normalized version of GAK that ensures that k(x,x) = 1
cdist_gak : Compute cross-similarity matrix using Global Alignment kernel
References
----------
.. [1] M. Cuturi, "Fast global alignment kernels," ICML 2011.
"""
s1 = to_time_series(s1, remove_nans=True)
s2 = to_time_series(s2, remove_nans=True)
gram = _gak_gram(s1, s2, sigma=sigma)
gak_val = njit_gak(s1, s2, gram)
return gak_val
float
Similarity score
Examples
--------
>>> path, dist = dtw_subsequence_path([2., 3.], [1., 2., 2., 3., 4.])
>>> path
[(0, 2), (1, 3)]
>>> dist
0.0
See Also
--------
dtw : Get the similarity score for DTW
"""
subseq = to_time_series(subseq)
longseq = to_time_series(longseq)
acc_cost_mat = njit_accumulated_matrix_subsequence(subseq=subseq,
longseq=longseq)
path = _return_path_subsequence(acc_cost_mat)
return path, numpy.sqrt(numpy.min(acc_cost_mat[-1, :]))
1.0
See Also
--------
dtw_path : Get both the matching path and the similarity score for DTW
cdist_dtw : Cross similarity matrix between time series datasets
References
----------
.. [1] H. Sakoe, S. Chiba, "Dynamic programming algorithm optimization for
spoken word recognition," IEEE Transactions on Acoustics, Speech and
Signal Processing, vol. 26(1), pp. 43--49, 1978.
"""
s1 = to_time_series(s1, remove_nans=True)
s2 = to_time_series(s2, remove_nans=True)
if global_constraint is not None:
global_constraint_str = global_constraint
else:
global_constraint_str = ""
mask = compute_mask(
s1, s2,
GLOBAL_CONSTRAINT_CODE[global_constraint_str],
sakoe_chiba_radius=sakoe_chiba_radius,
itakura_max_slope=itakura_max_slope)
return njit_dtw(s1, s2, mask=mask)
array([[2.],
[3.],
[3.],
[3.],
[2.]])
See also
--------
lb_keogh : Compute LB_Keogh similarity
References
----------
.. [1] Keogh, E. Exact indexing of dynamic time warping. In International
Conference on Very Large Data Bases, 2002. pp 406-417.
"""
return njit_lb_envelope(to_time_series(ts), radius=radius)
Parameters
----------
X: array, shape = [m, d]
First time series.
Y: array, shape = [n, d]
Second time series.
Examples
--------
>>> SquaredEuclidean([1, 2, 2, 3], [1, 2, 3, 4]).compute()
array([[0., 1., 4., 9.],
[1., 0., 1., 4.],
[1., 0., 1., 4.],
[4., 1., 0., 1.]])
"""
self.X = to_time_series(X).astype(numpy.float64)
self.Y = to_time_series(Y).astype(numpy.float64)
1.0
See Also
--------
dtw : Get only the similarity score for DTW
cdist_dtw : Cross similarity matrix between time series datasets
References
----------
.. [1] H. Sakoe, S. Chiba, "Dynamic programming algorithm optimization for
spoken word recognition," IEEE Transactions on Acoustics, Speech and
Signal Processing, vol. 26(1), pp. 43--49, 1978.
"""
s1 = to_time_series(s1, remove_nans=True)
s2 = to_time_series(s2, remove_nans=True)
if global_constraint is not None:
global_constraint_str = global_constraint
else:
global_constraint_str = ""
mask = compute_mask(
s1, s2, GLOBAL_CONSTRAINT_CODE[global_constraint_str],
sakoe_chiba_radius, itakura_max_slope
)
acc_cost_mat = njit_accumulated_matrix(s1, s2, mask=mask)
path = _return_path(acc_cost_mat)
return path, numpy.sqrt(acc_cost_mat[-1, -1])
>>> dtw([1, 2, 3], [1., 2., 2., 3., 4.])
1.0
See Also
--------
dtw_path : Get both the matching path and the similarity score for DTW
cdist_dtw : Cross similarity matrix between time series datasets
References
----------
.. [1] H. Sakoe, S. Chiba, "Dynamic programming algorithm optimization for
spoken word recognition," IEEE Transactions on Acoustics, Speech and
Signal Processing, vol. 26(1), pp. 43--49, 1978.
"""
s1 = to_time_series(s1, remove_nans=True)
s2 = to_time_series(s2, remove_nans=True)
if global_constraint is not None:
global_constraint_str = global_constraint
else:
global_constraint_str = ""
mask = compute_mask(
s1, s2,
GLOBAL_CONSTRAINT_CODE[global_constraint_str],
sakoe_chiba_radius=sakoe_chiba_radius,
itakura_max_slope=itakura_max_slope)
return njit_dtw(s1, s2, mask=mask)
... sigma=2.) # doctest: +ELLIPSIS
15.358...
>>> unnormalized_gak([1, 2, 3],
... [1., 2., 2., 3., 4.]) # doctest: +ELLIPSIS
3.166...
See Also
--------
gak : normalized version of GAK that ensures that k(x,x) = 1
cdist_gak : Compute cross-similarity matrix using Global Alignment kernel
References
----------
.. [1] M. Cuturi, "Fast global alignment kernels," ICML 2011.
"""
s1 = to_time_series(s1, remove_nans=True)
s2 = to_time_series(s2, remove_nans=True)
gram = _gak_gram(s1, s2, sigma=sigma)
gak_val = njit_gak(s1, s2, gram)
return gak_val