dtw

How to apply dtw algorithm on multiple time series in R?

我只是一个虾纸丫 提交于 2021-01-28 02:20:53
问题 Problem I have time series of speed of different vehicles. My ultimate objective is to cluster different vehicles based on their similarities in speed over time. So, I basically need to produce a distance matrix where each cell contains the distance between a pair of vehicle speed time series. I want to use Dynamic Time Warping (dtw) as distance metric. Therefore, I want to apply dtw on each pair of speed time series . Data Here are some sample data that contain only 8 observations per car

Clustering similar time series?

ⅰ亾dé卋堺 提交于 2020-12-30 08:14:23
问题 I have somewhere between 10-20k different time-series (24 dimensional data -- a column for each hour of the day) and I'm interested in clustering time series that exhibit roughly the same patterns of activity. I had originally started to implement Dynamic Time Warping (DTW) because: Not all of my time series are perfectly aligned Two slightly shifted time series for my purposes should be considered similar Two time series with the same shape but different scales should be considered similar

Parallel for loop over numpy matrix

你说的曾经没有我的故事 提交于 2020-06-27 19:41:07
问题 I am looking at the joblib examples but I can't figure out how to do a parallel for loop over a matrix. I am computing a pairwise distance metric between the rows of a matrix. So I was doing: N, _ = data.shape upper_triangle = [(i, j) for i in range(N) for j in range(i + 1, N)] dist_mat = np.zeros((N,N)) for (i, j) in upper_triangle: dist_mat[i,j] = dist_fun(data[i], data[j]) dist_mat[j,i] = dist_mat[i,j] where dist_fun takes two vectors and computes a distance. How can I make this loop

Parallel for loop over numpy matrix

依然范特西╮ 提交于 2020-06-27 19:40:13
问题 I am looking at the joblib examples but I can't figure out how to do a parallel for loop over a matrix. I am computing a pairwise distance metric between the rows of a matrix. So I was doing: N, _ = data.shape upper_triangle = [(i, j) for i in range(N) for j in range(i + 1, N)] dist_mat = np.zeros((N,N)) for (i, j) in upper_triangle: dist_mat[i,j] = dist_fun(data[i], data[j]) dist_mat[j,i] = dist_mat[i,j] where dist_fun takes two vectors and computes a distance. How can I make this loop

How to get distance matrix using dynamic time wraping?

隐身守侯 提交于 2020-06-17 09:32:08
问题 I have 6 timeseries values as follows. import numpy as np series = np.array([ [0., 0, 1, 2, 1, 0, 1, 0, 0], [0., 1, 2, 0, 0, 0, 0, 0, 0], [1., 2, 0, 0, 0, 0, 0, 1, 1], [0., 0, 1, 2, 1, 0, 1, 0, 0], [0., 1, 2, 0, 0, 0, 0, 0, 0], [1., 2, 0, 0, 0, 0, 0, 1, 1]]) Suppose, I want to get the distance matrix of dynamic time warping to perform a clustering. I used dtaidistance library for that as follows. from dtaidistance import dtw ds = dtw.distance_matrix_fast(series) The output I got was as

Investigating Neural Network based Query-by-Example Keyword Spotting Approach for Personalized Wake-

最后都变了- 提交于 2020-01-30 18:57:39
Investigating Neural Network based Query-by-Example Keyword Spotting Approach for Personalized Wake-up Word Detection in Mandarin Chinese 基于神经网络的示例查询关键词识别方法在普通话个性化唤醒词检测中的研究 Abstract 我们使用示例查询关键字查找(QbyE-KWS)方法来解决针对占地空间小,计算成本低的设备应用的个性化唤醒单词检测问题。 QbyE-KWS将关键字作为模板,并通过DTW在音频流中匹配模板,以查看是否包含关键字。在本文中,我们使用神经网络作为声学模型来提取DNN / LSTM音素的后验特征和LSTM嵌入特征。具体来说,我们研究了LSTM嵌入特征提取器,用于普通话中不同的建模单元,从音素到单词。我们还研究了两种流行的DTW方法的性能:S-DTW和SLN-DTW。 SLN-DTW无需在S-DTW方法中使用分段过程,就可以准确有效地搜索长音频流中的关键字。我们的研究表明,与S-DTW方法相比,DNN音素后验加SLN-DTW方法实现了最高的计算效率和最新性能,相对丢失率降低了78%。字级LSTM嵌入功能显示出比其他嵌入单元更高的性能。 索引词:关键字发现,唤醒词检测,DTW,示例查询,DNN,LSTM 1. Introduction

DTW + python 矩阵操作 + debug

你离开我真会死。 提交于 2020-01-19 00:57:10
1. from here . diagonal Return specified diagonals. diagflat Create a 2-D array with the flattened input as a diagonal. trace Sum along diagonals. triu Upper triangle of an array. tril Lower triangle of an array. 2. DTW distance. dtaidistance from dtaidistance import dtw ds = dtw.distance_matrix_fast(x) 3. sparce matrix in csr format. 4. Bug: AttributeError: module 'community' has no attribute 'best_partition' import community 但是安装包是不是安装community,而是安装pip intall python-louvain. 来源: https://www.cnblogs.com/dulun/p/12210829.html

Different results and performances with different libraries

随声附和 提交于 2019-12-30 11:01:53
问题 I'm comparing the libraries dtaidistance, fastdtw and cdtw for DTW computations. This is my code: from fastdtw import fastdtw from cdtw import pydtw import fastdtw import array from timeit import default_timer as timer from dtaidistance import dtw, dtw_visualisation as dtwvis s1 = mySampleSequences[0] # first sample sequence consisting of 3000 samples s2 = mySampleSequences[1] # second sample sequence consisting of 3000 samples start = timer() distance1 = dtw.distance(s1, s2) end = timer()

机器学习距离公式总结

*爱你&永不变心* 提交于 2019-12-25 13:11:40
作者:daniel-D 出处:http://www.cnblogs.com/daniel-D/ 在机器学习和数据挖掘中,我们经常需要知道个体间差异的大小,进而评价个体的相似性和类别。最常见的是数据分析中的相关分析,数据挖掘中的分类和聚类算法,如 K 最近邻(KNN)和 K 均值(K-Means)等等。根据数据特性的不同,可以采用不同的度量方法。一般而言,定义一个距离函数 d(x,y), 需要满足下面几个准则: 1) d(x,x) = 0 // 到自己的距离为0 2) d(x,y) >= 0 // 距离非负 3) d(x,y) = d(y,x) // 对称性: 如果 A 到 B 距离是 a,那么 B 到 A 的距离也应该是 a 4) d(x,k)+ d(k,y) >= d(x,y) // 三角形法则: (两边之和大于第三边) 这篇博客主要介绍机器学习和数据挖掘中一些常见的距离公式,包括: 闵可夫斯基距离 欧几里得距离 曼哈顿距离 切比雪夫距离 马氏距离 余弦相似度 皮尔逊相关系数 汉明距离 杰卡德相似系数 编辑距离 DTW 距离 KL 散度 1. 闵可夫斯基距离 闵可夫斯基距离(Minkowski distance)是衡量数值点之间距离的一种非常常见的方法,假设数值点 P 和 Q 坐标如下: 那么,闵可夫斯基距离定义为: 该距离最常用的 p 是 2 和 1, 前者是欧几里得距离

vector memory exhausted using R package dtw

早过忘川 提交于 2019-12-11 15:19:31
问题 I am trying to use R package dtw to calculate the distance between two numeric vectors. Here is a sample of my code: testNumbers <- sample(seq(from = 1, to = 60), size = 60000, replace = TRUE) testNumbers2 <- sample(seq(from = 1, to = 60), size = 60000, replace = TRUE) Sys.setenv('R_MAX_VSIZE'=32000000000) Sys.getenv('R_MAX_VSIZE') dtw(testNumbers, testNumbers2, distance.only = TRUE) I will be using wav files that have been decoded, but that hasn't worked either, so I've been using this