12
1 Presented by Dr Khurram Khurshid DYNAMIC TIME WARPING (Application in Pattern Recognition)

07 Edit Distance DTW

Embed Size (px)

DESCRIPTION

Edit Distance DTW, to fnd the matching among words

Citation preview

Page 1: 07 Edit Distance DTW

1

Presented by

Dr Khurram Khurshid

DYNAMIC TIME WARPING (Application in Pattern Recognition)

Page 2: 07 Edit Distance DTW

2

DTW Compare 2 sequences varying in time (speech)

• Different sizes

• Extended in time

0 0 1 1 0 0 1 1 1 1 0

0 0 0 1 1 1 0 0 0 1 1 1 1 1 1 1 0

Page 3: 07 Edit Distance DTW

3

Using DTW

x1 x2 x3 x4 x5 x6 x7

( 0 1 1 0 0 0 1 )

1 y5

1 y4

1 y3

1 y2

0 y1

Page 4: 07 Edit Distance DTW

4

Steps:• D (1,1) = d (x1,y1)

• For m = 2 to 7

• D (m,1) = D (m-1, 1) + d (xm,y1)

• For n = 2 to 5

• D (1,n) = D (1, n –1) + d (x1,yn)

DTW

Page 5: 07 Edit Distance DTW

5

D(i, j –1)

D (i , j) = min D(i-1, j) + d (x i,yi)D (i-1, j-1)

  

Here for d (xi , yi), we can just use the Euclidean distance.    d

d (xi , yi) = ∑ (x i,k - y j,k)2

K=1

DTW

Page 6: 07 Edit Distance DTW

6

Using DTW

4 0 0 1 2 2 2

3 0 0 1 2 2 2

2 0 0 1 2 2 2

1 0 0 1 2 2 2

0 1 2 2 2 3 4

x1 x2 x3 x4 x5 x6 x7

( 0 1 1 0 0 1 1 )

1 y5

1 y4

1 y3

1 y2

0 y1

Page 7: 07 Edit Distance DTW

7

STRING COMPARISON

Page 8: 07 Edit Distance DTW

8

ISSUES

Scale Invariance

Translation Invariance

Page 9: 07 Edit Distance DTW

9

EDIT / LEVENSHTEIN DISTANCE Given strings s and t

Distance is shortest sequence of edit commands that transform s to t, (or equivalently t to s).

Simple set of operations: Copy character from s over to t (cost 0) Delete a character in s (cost 1) Insert a character in t (cost 1) Substitute one character for another (cost 1)

Page 10: 07 Edit Distance DTW

10

EDIT / LEVENSHTEIN DISTANCE

Page 11: 07 Edit Distance DTW

11

EDIT / LEVENSHTEIN DISTANCE

Distance between SATURDAY and SUNDAY?

Page 12: 07 Edit Distance DTW

12

EDIT / LEVENSHTEIN DISTANCE