You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a sequence matching problem. I cannot figure out a way to find the best match using a single execution. I kind of using dist to move step by step and figure out the corresponding smallest position.
Could you give me some hints, how to use 1 dtw process to figure out the best match?
below is the code, modified a little from the example
importnumpyasnpfromdtwimportdtw , accelerated_dtwimportrandomimportmatplotlib.pyplotasplt# We define two sequences x, y as numpy array# where y is actually a sub-sequence from xx=np.array([3,9,9,8,7,2,2, 0, 1, 1.2, 0, 3, 2, 4.3, 2.3, 1, 2.2, 0]).reshape(-1, 1) +2.0y=np.array([ 1, 1.1, 3.5,2, 2, 1, 4.2, 2.1, 1, 2.5, 0]).reshape(-1, 1)
x=x.reshape(-1).tolist()
# added some random samplesforiinrange(15):
x.append(random.randint(0,99)/10.0)
x=np.array(x)
euclidean_norm=lambdax, y: np.abs(x-y)
ds= []
foriinrange(x.shape[0] -y.shape[0]-1):
d, cost_matrix, acc_cost_matrix, path=accelerated_dtw(x[i:i+y.shape[0]], y, dist=euclidean_norm, warp=1)
ds.append(d)
ds=np.array(ds)
# figure out the positionoffset=np.argmin(ds)
print(offset)
plt.plot(x)
ifoffset>0:
# padding zeros, align itz=np.zeros(offset)
z=z.tolist()
z.extend(y.reshape(-1).tolist())
print(z)
z=np.array(z)
plt.plot(z)
else:
plt.plot(y)
plt.show()
The text was updated successfully, but these errors were encountered:
I'm working on a sequence matching problem. I cannot figure out a way to find the best match using a single execution. I kind of using dist to move step by step and figure out the corresponding smallest position.
Could you give me some hints, how to use 1 dtw process to figure out the best match?
below is the code, modified a little from the example
The text was updated successfully, but these errors were encountered: