07 edit distance-dtw

Post on 07-Aug-2015

56 views 2 download

Transcript of 07 edit distance-dtw

1

Presented by

Dr Khurram Khurshid

DYNAMIC TIME WARPING (Application in Pattern Recognition)

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

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

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

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

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

7

STRING COMPARISON

8

ISSUES

Scale Invariance

Translation Invariance

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)

10

EDIT / LEVENSHTEIN DISTANCE

11

EDIT / LEVENSHTEIN DISTANCE

Distance between SATURDAY and SUNDAY?

12

EDIT / LEVENSHTEIN DISTANCE