SlideShare ist ein Scribd-Unternehmen logo
1 von 74
Workshop on tree distance By Hector Franco francoph at tcd dot ie Trinity College of Dublin
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
String  distance metrics: Levenshtein ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Levenshtein distance - example ,[object Object],S Domain: T Range: op cost alignment W I L L I A M _ C O H E N W I L L L I A M _ C O H O N C C C C I C C C C C C C S C 0 0 0 0 1 1 1 1 1 1 1 1 2 2
Computing Levenshtein distance D(i,j) = score of  best  alignment from  s1..si  to  t1..tj = min D(i-1,j-1) + d(si,tj)  //subst/copy D(i-1,j)+1  //insert D(i,j-1)+1  //delete (simplify by letting d(c,d)=0 if c=d, 1 else) also let D(i,0)=i  (for i inserts)  and D(0,j)=j
Computing Levenshtein distance - 3 D(i,j)= min D(i-1,j-1) + d(si,tj)  //subst/copy D(i-1,j)+1  //insert D(i,j-1)+1  //delete The yellow row and column, correspond to the row 0 and column 0 of the table, and they are initiated in increasing order. For (int x = 0; x<size(target), x++) D(0,x) = x; For (int x = 0; x<size(source), x++) D(x,0) = x; d(si,tj) represents the cost of change the letter si into the letter tj, where if the letter is the same the cost will be 0 and if is a different letter the cost will be 1.  = D( s,t ) C O H E N 0 1 2 3 4 5 M 1 1 2 3 4 5 C 2 1 2 3 4 5 C 3 2 2 3 4 5 O 4 3 2 3 4 5 H 5 4 3 2 3 4 N 6 5 4 3 3 3
Computing Levenshtein distance - 3 D(i,j)= min D(i-1,j-1) + d(si,tj)  //subst/copy D(i-1,j)+1  //insert D(i,j-1)+1  //delete C O H E N 0 1 2 3 4 5 M 1 1 2 3 4 5 C 2 1 2 3 4 5 C 3 2 2 3 4 5 O 4 3 2 3 4 5 H 5 4 3 2 3 4 N 6 5 4 3 3 3 T1 T2 Cost M - 1 C - 1 C C 0 O O 0 H H 0 - E 1 N N 0 T1 T2 Cost M - 1 C C 0 C - 1 O O 0 H H 0 - E 1 N N 0
Practice G O O D G O D G O D TRY TRY G O O D 0 1 2 3 4 G 1 0 1 2 3 O 2 1 0 1 2 D 3 2 1 1 1
Sub string matching  ,[object Object],Look for the minimum value “ niver” Cost 0 for delete positions before the sub-string u n i v e r s 0 0 0 0 0 0 0 n 1 0 1 1 1 1 1 i 2 1 0 1 2 2 2 e 3 2 1 1 1 2 3 r 4 3 2 2 2 1 2
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Edit distance between trees ,[object Object],[object Object],[object Object],[object Object]
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Post-order traversal of trees ,[object Object],[object Object],[object Object],[object Object]
practice yourself 1 5 3 2 4
Ancestors:
Left most descendent Function l(x) give as the most left descendent of the node x
Key roots x is a key root if:
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Mappings M H S I I S S B Domain: Range:  Deleted: in the domain: Changed Exact match Inserted: in the range
Mappings M H S I I S S B Domain: Range:  Transformation = { 1,2 } , { 2,    } , { 3,1 } , { 4,4 } , {  ,3 } Note: this is NOT a tai map.  1 1 2 2 3 3 4 4
The sets TR: Transformations  M: Map C: change Cost =1 EX: exact match Cost = 0 I: Insertion Cost = 1 D: deletion Cost= 1 TR = EX + C + I + D  M = EX + C M H S I I S S B Domain: Range:  1 1 2 2 3 3 4 4
Mappings ,[object Object],[object Object],[object Object],[object Object],[object Object],TR =  { 1,2 } , { 2,    } ,  { 3,1 } ,  { 4,4 } ,  {  ,3 }  M H S I I S S B Domain: Range:  1 1 2 2 3 3 4 4
Mappings more formal ,[object Object],[object Object],[object Object],[object Object]
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Tai mapping: a restricted map ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],c f b d e a
practice ,[object Object],Ancestry! multiple! Possible tai mapping Sibling order 1 2 3 4 3 2 1 5 4 1 5 3 2 4
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Definition : Tree distance ,[object Object],[object Object],[object Object]
Practice:  prove the “triangle inequality” Prove:    (M3)      (M1)+   (M2) | M3 = M1*M2 Clue:    (M0) = |C0|+|I0|+|D0| TR: Transformations  M: Map C: change Cost =1 EX: exact match Cost = 0 I: Insertion Cost = 1 D: deletion Cost= 1 TR: Transformations  M: Map C: change Cost =1 EX: exact match Cost = 0 I: Insertion Cost = 1 D: deletion Cost= 1
Practice All possible combinations of the set m1 and m2 in m3 gives same or less cost combined, than alone.  SET1 COST SET2 COST SET3 COST DIFF EX 0 EX 0 EX 0 0 EX 0 C 1 C 1 0 EX 0 D 1 D 1 0 C 1 EX 0 C 1 0 C 1 C 1 C/EX 1/0 -1/-2 C 1 D 1 D 1 -1 I 1 EX 0 I 1 0 I 1 C 1 I 1 -1 I 1 D 1 None 0 -2 D 1 None 0 D 1 0 D 1 I 1 C/EX 1/0 -1/-2 None 0 I 1 I 1 0
summary ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Zhang shasha algorithm ,[object Object],[object Object],[object Object],[object Object]
Forest Distance ,[object Object],[object Object],Tree Tree Tree Forest Tree
Tree distance  (  ,  )+  ( )  (  ,  )= min  (  ,  )+  ( )  (  ,  )+  ( ) delete add change
Forest distance  (  ,  ) = min  (  ,  )+  ( )  (  ,  )+  ( ) delete add  (  ,  )+   (  ,  )
Why this is not allowed? Clue: check tai mapping restrictions  (  ,  )+  ( )  (  ,  ) = min  (  ,  )+  ( )  (  ,  )+  ( ) delete add change
 (  ,  )+  ( )  (  ,  )= change
Algoritm: psedudo code ,[object Object],[object Object],[object Object],[object Object]
Algoritm: 2 ,[object Object],prepare forest table
Algoritm: 3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Algoritm: 4 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Sample ,[object Object],[object Object],[object Object],6 5 2 1 3 4 6 2 4 1 3 5 t1 t2 6 6 5
Sample ,[object Object],[object Object],[object Object],[object Object],[object Object],t1 t2 6 5 2 1 3 4 6 2 4 1 3 5 0 1 2 3 4 5 6 Nan 1 1 3 4 1 1 Nan 1 1 3 3 5 1 Nan 0 0 1 1 0 1 Nan 0 0 0 1 1 1
Most left ,[object Object],[object Object],[object Object],[object Object],[object Object],t1 t2 6 5 2 1 3 4 6 2 4 1 3 5 0 1 2 3 4 5 6 Nan 1 1 3 4 1 1 Nan 1 1 3 3 5 1 Nan 0 0 1 1 0 1 Nan 0 0 0 1 1 1
Key roots ,[object Object],[object Object],[object Object],[object Object],[object Object],t1 t2 6 5 2 1 3 4 6 2 4 1 3 5 0 1 2 3 4 5 6 Nan 1 1 3 4 1 1 Nan 1 1 3 3 5 1 Nan 0 0 1 1 0 1 Nan 0 0 0 1 1 1
Atomic cost: c ,[object Object],[object Object],6 5 2 1 3 4 6 2 4 1 3 5 t1 t2 1 2 3 4 5 6 1 2 3 4 5 6   - 1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 1 1 0 1 0 1 1
Tree distance table ,[object Object],[object Object],[object Object],[object Object],t1 t2 0  1  2  3  4  5  6 01  23  456 6 5 2 1 3 4 6 2 4 1 3 5 - - - - - - - - N N N N N N - N N N N N N - N N N N N N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,4) ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],- - - - - - - - N N N N N N - N N N N N N - N N N N N N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,4) step2 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],T(  ,  )= min 3 3 F(  ,  )+   (  )=2 3 F(  ,  )+   (  )=2 F(  ,   )+  (  )=0 3 3 3 3 ,[object Object],[object Object],[object Object],0 1 2 1 0 - - - - - - - - N N N N N N - N N N N N N - N N 0 N N N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,4) step3 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],T(  ,  )= min 3 F(  ,  )+   (  )=3 F(  ,  )+   (  )=1 F(  ,  ) +  (  )=2 3 3 4 4 4 3 4 3 3 3 0 1 2 1 0 1 - - - - - - - - N N N N N N - N N N N N N - N N 0 1 N N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,5) step1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],- - - - - - - - N N N N N N - N N N N N N - N N 0 1 N N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,5) step2 ,[object Object],[object Object],[object Object],[object Object],[object Object],T(  ,  )= min 3 5 F(  ,  )+   (  )=2 5 F(  ,  )+   (  )=2 F(  ,   )+  (  )=0 3 3 5 5 - - - - - - - - N N N N N N - N N N N N N - N N 0 1 0 N - N N N N N N - N N N N N N - N N N N N N 0 1 1 0
Treedist(3,6) step1 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],0 1 2 3 4 5 6 1 - - - - - - - - N N N N N N - N N N N N N - N N 0 1 0 N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,6) step2 ,[object Object],[object Object],[object Object],[object Object],[object Object],T(  ,  )= min 3 F(  ,  )+   (  )=2 F(  ,     )+   (  )=2 F(  ,   )+  (  )=0 3 3 1 1 1 1 0 1 2 3 4 5 6 1 0 - - - - - - - - N N N N N N - N N N N N N - 0 N 0 1 0 N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,6) step3 ,[object Object],[object Object],[object Object],[object Object],[object Object],T(  ,  )= min 3 F(  ,  )+   (  )=2 F(  ,  )+   (  )=1 F(  ,  )+  (  )=2 3 3 2 2 2 1 2 1 1 1 0 1 2 3 4 5 6 1 0 1 - - - - - - - - N N N N N N - N N N N N N - 0 1 0 1 0 N - N N N N N N - N N N N N N - N N N N N N
Treedist(3,6) step4 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],T(  ,  )= min 3 F(  ,  )+   (  )=4 F(  ,  )+   (  )=2 F(  ,  )+T(  , )=2 3 3 2 3 3 ,[object Object],[object Object],0 1 2 3 4 5 6 1 0 1 2 - - - - - - - - N N N N N N - N N N N N N - 0 1 0 1 0 N - N N N N N N - N N N N N N - N N N N N N 2 1 3 2 1 3 2 1 2 1
Treedist(3,6) step5 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],T(  ,  )= min 3 F(  ,  )+   (  )=5 F(  ,  )+   (  )=3 F(  ,  )+T(  ,  )=3 3 3 2 3 Size of forest 0 1 2 3 4 5 6 1 0 1 2 3 - - - - - - - - N N N N N N - N N N N N N - 0 1 0 1 0 N - N N N N N N - N N N N N N - N N N N N N 2 1 2 4 1 3 2 4 1 3 2 1 3 4 3
 
[object Object],[object Object],Key roots t1 6 5 2 1 3 4 2 4 1 3 t2
[object Object],[object Object],[object Object],[object Object],Key roots t1 6 5 2 1 3 4 2 4 1 3 t2
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Key roots t1 6 5 2 1 3 4 2 4 1 3 t2
[object Object],[object Object],Key roots t1 6 5 2 1 3 4 2 4 1 3 t2
[object Object],[object Object],Key roots t1 We need the result of the matching for the sub-trees nodes 3 and 4,  and it happen that hey are key roots! 6 5 2 1 3 4 2 4 1 3 t2 2 1 3 4  (  ,  ) = min  (  ,  )+  ( )  (  ,  )+  ( ) delete add  (  ,  )+   (  ,  )
Practice: ,[object Object],G o o d G o d Forest table  =  tree table  =  levenshtein table.
Tree distance ,[object Object],[object Object]
Calculate the alignment ,[object Object],[object Object],The algorithm can be extended in order to get the alignment: All tables are need it. This talbes corresponds to the same example as we looked before.  - - - - - - - - 0 1 0 1 0 5 - 1 0 1 0 1 4 - 0 1 0 1 0 5 - 0 1 0 1 0 5 - 4 3 4 3 4 2 - 5 4 5 4 5 3 0 1 2 3 4 5 6 1 0 1 2 3 4 5 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 2 1 2 5 4 3 2 3 2 2 6 5 4 3 4 3 3
Calculate the alignment ,[object Object],[object Object],(6,6) - - - - - - - - 0 1 0 1 0 5 - 1 0 1 0 1 4 - 0 1 0 1 0 5 - 0 1 0 1 0 5 - 4 3 4 3 4 2 - 5 4 5 4 5 3 0 1 2 3 4 5 6 1 0 1 2 3 4 5 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 2 1 2 5 4 3 2 3 2 2 6 5 4 3 4 3 3
Calculate the alignment ,[object Object],[object Object],(6,6),  - - - - - - - - 0 1 0 1 0 5 - 1 0 1 0 1 4 - 0 1 0 1 0 5 - 0 1 0 1 0 5 - 4 3 4 3 4 2 - 5 4 5 4 5 3 0 1 2 3 4 5 6 1 0 1 2 3 4 5 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 2 1 2 5 4 3 2 3 2 2 6 5 4 3 4 3 3
Calculate the alignment ,[object Object],[object Object],(6,6), (4,5)  - - - - - - - - 0 1 0 1 0 5 - 1 0 1 0 1 4 - 0 1 0 1 0 5 - 0 1 0 1 0 5 - 4 3 4 3 4 2 - 5 4 5 4 5 3 0 1 2 3 4 5 6 1 0 1 2 3 4 5 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 2 1 2 5 4 3 2 3 2 2 6 5 4 3 4 3 3
Calculate the alignment ,[object Object],[object Object],(6,6), (4,5)  - - - - - - - - 0 1 0 1 0 5 - 1 0 1 0 1 4 - 0 1 0 1 0 5 - 0 1 0 1 0 5 - 4 3 4 3 4 2 - 5 4 5 4 5 3 0 1 2 3 4 5 6 1 0 1 2 3 4 5 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 2 1 2 5 4 3 2 3 2 2 6 5 4 3 4 3 3
Calculate the alignment ,[object Object],[object Object],(6,6), (4,5), (2,2)  - - - - - - - - 0 1 0 1 0 5 - 1 0 1 0 1 4 - 0 1 0 1 0 5 - 0 1 0 1 0 5 - 4 3 4 3 4 2 - 5 4 5 4 5 3 0 1 2 3 4 5 6 1 0 1 2 3 4 5 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 2 1 2 5 4 3 2 3 2 2 6 5 4 3 4 3 3
Calculate the alignment ,[object Object],[object Object],(6,6), (4,5), (2,2), (1,1).  - - - - - - - - 0 1 0 1 0 5 - 1 0 1 0 1 4 - 0 1 0 1 0 5 - 0 1 0 1 0 5 - 4 3 4 3 4 2 - 5 4 5 4 5 3 0 1 2 3 4 5 6 1 0 1 2 3 4 5 2 1 0 1 2 3 4 3 2 1 0 1 2 3 4 3 2 1 2 1 2 5 4 3 2 3 2 2 6 5 4 3 4 3 3
THANKS FOR YOUR ATENTION

Weitere ähnliche Inhalte

Was ist angesagt?

SVM Algorithm Explained | Support Vector Machine Tutorial Using R | Edureka
SVM Algorithm Explained | Support Vector Machine Tutorial Using R | EdurekaSVM Algorithm Explained | Support Vector Machine Tutorial Using R | Edureka
SVM Algorithm Explained | Support Vector Machine Tutorial Using R | EdurekaEdureka!
 
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...Edureka!
 
Graceful labelings
Graceful labelingsGraceful labelings
Graceful labelingsradhikamathy
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtrackingmandlapure
 
Function and Its Types.
Function and Its Types.Function and Its Types.
Function and Its Types.Awais Bakshy
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree methodRajendran
 
introduction to graph theory
introduction to graph theoryintroduction to graph theory
introduction to graph theoryChuckie Balbuena
 
Ch 2 lattice & boolean algebra
Ch 2 lattice & boolean algebraCh 2 lattice & boolean algebra
Ch 2 lattice & boolean algebraRupali Rana
 
An Introduction to Spectral Graph Theory
An Introduction to Spectral Graph TheoryAn Introduction to Spectral Graph Theory
An Introduction to Spectral Graph Theoryjoisino
 
Linear models for classification
Linear models for classificationLinear models for classification
Linear models for classificationSung Yub Kim
 
R Programming Language
R Programming LanguageR Programming Language
R Programming LanguageNareshKarela1
 
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...Simplilearn
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithmMohd Arif
 

Was ist angesagt? (20)

Graph Theory
Graph TheoryGraph Theory
Graph Theory
 
SVM Algorithm Explained | Support Vector Machine Tutorial Using R | Edureka
SVM Algorithm Explained | Support Vector Machine Tutorial Using R | EdurekaSVM Algorithm Explained | Support Vector Machine Tutorial Using R | Edureka
SVM Algorithm Explained | Support Vector Machine Tutorial Using R | Edureka
 
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
 
Graceful labelings
Graceful labelingsGraceful labelings
Graceful labelings
 
01 knapsack using backtracking
01 knapsack using backtracking01 knapsack using backtracking
01 knapsack using backtracking
 
Function and Its Types.
Function and Its Types.Function and Its Types.
Function and Its Types.
 
Strongly Connected Components
Strongly Connected Components Strongly Connected Components
Strongly Connected Components
 
Hierarchical Clustering
Hierarchical ClusteringHierarchical Clustering
Hierarchical Clustering
 
Recursion tree method
Recursion tree methodRecursion tree method
Recursion tree method
 
Naive bayes
Naive bayesNaive bayes
Naive bayes
 
introduction to graph theory
introduction to graph theoryintroduction to graph theory
introduction to graph theory
 
Ch 2 lattice & boolean algebra
Ch 2 lattice & boolean algebraCh 2 lattice & boolean algebra
Ch 2 lattice & boolean algebra
 
An Introduction to Spectral Graph Theory
An Introduction to Spectral Graph TheoryAn Introduction to Spectral Graph Theory
An Introduction to Spectral Graph Theory
 
Linear models for classification
Linear models for classificationLinear models for classification
Linear models for classification
 
Ridge regression
Ridge regressionRidge regression
Ridge regression
 
R Programming Language
R Programming LanguageR Programming Language
R Programming Language
 
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
 
Chap4
Chap4Chap4
Chap4
 
Dinive conquer algorithm
Dinive conquer algorithmDinive conquer algorithm
Dinive conquer algorithm
 
XGBoost (System Overview)
XGBoost (System Overview)XGBoost (System Overview)
XGBoost (System Overview)
 

Andere mochten auch

Clustering Homogenous XML Documents (CS501 Final Report) (1)
Clustering Homogenous XML Documents (CS501 Final Report) (1)Clustering Homogenous XML Documents (CS501 Final Report) (1)
Clustering Homogenous XML Documents (CS501 Final Report) (1)Abdussalam Alawini
 
Ortholog assignment
Ortholog assignmentOrtholog assignment
Ortholog assignmentMelvin Zhang
 
Licão 05 3ºtrimestre2014
Licão 05 3ºtrimestre2014Licão 05 3ºtrimestre2014
Licão 05 3ºtrimestre2014Junia Queles
 
Продолжаем говорить про арифметику
Продолжаем говорить про арифметикуПродолжаем говорить про арифметику
Продолжаем говорить про арифметикуAndrey Akinshin
 
Multiple sequence alignment
Multiple sequence alignmentMultiple sequence alignment
Multiple sequence alignmentgoneshwar
 
sequence alignment
sequence alignmentsequence alignment
sequence alignmentammar kareem
 
Introduction to sequence alignment
Introduction to sequence alignmentIntroduction to sequence alignment
Introduction to sequence alignmentKubuldinho
 
PyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at ScalePyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at ScaleGoDataDriven
 
L06 stemmer and edit distance
L06 stemmer and edit distanceL06 stemmer and edit distance
L06 stemmer and edit distanceananth
 
Genuine semantic publishing
Genuine semantic publishingGenuine semantic publishing
Genuine semantic publishingTobias Kuhn
 
Vida afetiva à luz do Espiritismo
Vida afetiva à luz do EspiritismoVida afetiva à luz do Espiritismo
Vida afetiva à luz do EspiritismoJorge Elarrat
 
Поговорим про арифметику
Поговорим про арифметикуПоговорим про арифметику
Поговорим про арифметикуAndrey Akinshin
 

Andere mochten auch (18)

Clustering Homogenous XML Documents (CS501 Final Report) (1)
Clustering Homogenous XML Documents (CS501 Final Report) (1)Clustering Homogenous XML Documents (CS501 Final Report) (1)
Clustering Homogenous XML Documents (CS501 Final Report) (1)
 
Ortholog assignment
Ortholog assignmentOrtholog assignment
Ortholog assignment
 
Lição 12 perdão, o antídoto para o rancor
Lição 12 perdão, o antídoto para o rancorLição 12 perdão, o antídoto para o rancor
Lição 12 perdão, o antídoto para o rancor
 
Licão 05 3ºtrimestre2014
Licão 05 3ºtrimestre2014Licão 05 3ºtrimestre2014
Licão 05 3ºtrimestre2014
 
Продолжаем говорить про арифметику
Продолжаем говорить про арифметикуПродолжаем говорить про арифметику
Продолжаем говорить про арифметику
 
Ressentimento ou perdão
Ressentimento ou perdãoRessentimento ou perdão
Ressentimento ou perdão
 
Homology
HomologyHomology
Homology
 
Multiple sequence alignment
Multiple sequence alignmentMultiple sequence alignment
Multiple sequence alignment
 
Raiva
RaivaRaiva
Raiva
 
sequence alignment
sequence alignmentsequence alignment
sequence alignment
 
Introduction to sequence alignment
Introduction to sequence alignmentIntroduction to sequence alignment
Introduction to sequence alignment
 
PyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at ScalePyData Amsterdam - Name Matching at Scale
PyData Amsterdam - Name Matching at Scale
 
L06 stemmer and edit distance
L06 stemmer and edit distanceL06 stemmer and edit distance
L06 stemmer and edit distance
 
Raiva.
Raiva.Raiva.
Raiva.
 
Perdão na visão espírita
Perdão na visão espíritaPerdão na visão espírita
Perdão na visão espírita
 
Genuine semantic publishing
Genuine semantic publishingGenuine semantic publishing
Genuine semantic publishing
 
Vida afetiva à luz do Espiritismo
Vida afetiva à luz do EspiritismoVida afetiva à luz do Espiritismo
Vida afetiva à luz do Espiritismo
 
Поговорим про арифметику
Поговорим про арифметикуПоговорим про арифметику
Поговорим про арифметику
 

Ähnlich wie Tree distance algorithm

Problem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element MethodProblem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element MethodPeter Herbert
 
SURF 2012 Final Report(1)
SURF 2012 Final Report(1)SURF 2012 Final Report(1)
SURF 2012 Final Report(1)Eric Zhang
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanationsGopi Saiteja
 
from_data_to_differential_equations.ppt
from_data_to_differential_equations.pptfrom_data_to_differential_equations.ppt
from_data_to_differential_equations.pptashutoshvb1
 
2_EditDistance_Jan_08_2020.pptx
2_EditDistance_Jan_08_2020.pptx2_EditDistance_Jan_08_2020.pptx
2_EditDistance_Jan_08_2020.pptxAnum Zehra
 
lecture 15
lecture 15lecture 15
lecture 15sajinsc
 
A Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabA Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabaiQUANT
 
Cgo2007 P3 3 Birkbeck
Cgo2007 P3 3 BirkbeckCgo2007 P3 3 Birkbeck
Cgo2007 P3 3 BirkbeckaiQUANT
 
Crib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC examsCrib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC examsA Jorge Garcia
 
Fourier Specturm via MATLAB
Fourier Specturm via MATLABFourier Specturm via MATLAB
Fourier Specturm via MATLABZunAib Ali
 
Paper computer
Paper computerPaper computer
Paper computerbikram ...
 
Paper computer
Paper computerPaper computer
Paper computerbikram ...
 
Conjugate Gradient Methods
Conjugate Gradient MethodsConjugate Gradient Methods
Conjugate Gradient MethodsMTiti1
 
torsionbinormalnotes
torsionbinormalnotestorsionbinormalnotes
torsionbinormalnotesJeremy Lane
 

Ähnlich wie Tree distance algorithm (20)

Problem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element MethodProblem Solving by Computer Finite Element Method
Problem Solving by Computer Finite Element Method
 
SURF 2012 Final Report(1)
SURF 2012 Final Report(1)SURF 2012 Final Report(1)
SURF 2012 Final Report(1)
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanations
 
from_data_to_differential_equations.ppt
from_data_to_differential_equations.pptfrom_data_to_differential_equations.ppt
from_data_to_differential_equations.ppt
 
2_EditDistance_Jan_08_2020.pptx
2_EditDistance_Jan_08_2020.pptx2_EditDistance_Jan_08_2020.pptx
2_EditDistance_Jan_08_2020.pptx
 
lecture 15
lecture 15lecture 15
lecture 15
 
D021018022
D021018022D021018022
D021018022
 
Lect5 v2
Lect5 v2Lect5 v2
Lect5 v2
 
A Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in MatlabA Dimension Abstraction Approach to Vectorization in Matlab
A Dimension Abstraction Approach to Vectorization in Matlab
 
Cgo2007 P3 3 Birkbeck
Cgo2007 P3 3 BirkbeckCgo2007 P3 3 Birkbeck
Cgo2007 P3 3 Birkbeck
 
kactl.pdf
kactl.pdfkactl.pdf
kactl.pdf
 
Week 4
Week 4Week 4
Week 4
 
2_1 Edit Distance.pptx
2_1 Edit Distance.pptx2_1 Edit Distance.pptx
2_1 Edit Distance.pptx
 
Online Signals and Systems Assignment Help
Online Signals and Systems Assignment HelpOnline Signals and Systems Assignment Help
Online Signals and Systems Assignment Help
 
Crib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC examsCrib Sheet AP Calculus AB and BC exams
Crib Sheet AP Calculus AB and BC exams
 
Fourier Specturm via MATLAB
Fourier Specturm via MATLABFourier Specturm via MATLAB
Fourier Specturm via MATLAB
 
Paper computer
Paper computerPaper computer
Paper computer
 
Paper computer
Paper computerPaper computer
Paper computer
 
Conjugate Gradient Methods
Conjugate Gradient MethodsConjugate Gradient Methods
Conjugate Gradient Methods
 
torsionbinormalnotes
torsionbinormalnotestorsionbinormalnotes
torsionbinormalnotes
 

Mehr von Trector Rancor

Cryptocurrencies overview
Cryptocurrencies overviewCryptocurrencies overview
Cryptocurrencies overviewTrector Rancor
 
A Comparative Study On Featuree Selection In Text2
A Comparative Study On Featuree Selection In Text2A Comparative Study On Featuree Selection In Text2
A Comparative Study On Featuree Selection In Text2Trector Rancor
 

Mehr von Trector Rancor (7)

Cryptocurrencies overview
Cryptocurrencies overviewCryptocurrencies overview
Cryptocurrencies overview
 
Virtual Journalist
Virtual JournalistVirtual Journalist
Virtual Journalist
 
Class Diagram Uml
Class Diagram UmlClass Diagram Uml
Class Diagram Uml
 
A Comparative Study On Featuree Selection In Text2
A Comparative Study On Featuree Selection In Text2A Comparative Study On Featuree Selection In Text2
A Comparative Study On Featuree Selection In Text2
 
Borderline Smote
Borderline SmoteBorderline Smote
Borderline Smote
 
going to uni
going to unigoing to uni
going to uni
 
My First Presentation
My First PresentationMy First Presentation
My First Presentation
 

Kürzlich hochgeladen

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 

Kürzlich hochgeladen (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 

Tree distance algorithm

  • 1. Workshop on tree distance By Hector Franco francoph at tcd dot ie Trinity College of Dublin
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Computing Levenshtein distance D(i,j) = score of best alignment from s1..si to t1..tj = min D(i-1,j-1) + d(si,tj) //subst/copy D(i-1,j)+1 //insert D(i,j-1)+1 //delete (simplify by letting d(c,d)=0 if c=d, 1 else) also let D(i,0)=i (for i inserts) and D(0,j)=j
  • 7. Computing Levenshtein distance - 3 D(i,j)= min D(i-1,j-1) + d(si,tj) //subst/copy D(i-1,j)+1 //insert D(i,j-1)+1 //delete The yellow row and column, correspond to the row 0 and column 0 of the table, and they are initiated in increasing order. For (int x = 0; x<size(target), x++) D(0,x) = x; For (int x = 0; x<size(source), x++) D(x,0) = x; d(si,tj) represents the cost of change the letter si into the letter tj, where if the letter is the same the cost will be 0 and if is a different letter the cost will be 1. = D( s,t ) C O H E N 0 1 2 3 4 5 M 1 1 2 3 4 5 C 2 1 2 3 4 5 C 3 2 2 3 4 5 O 4 3 2 3 4 5 H 5 4 3 2 3 4 N 6 5 4 3 3 3
  • 8. Computing Levenshtein distance - 3 D(i,j)= min D(i-1,j-1) + d(si,tj) //subst/copy D(i-1,j)+1 //insert D(i,j-1)+1 //delete C O H E N 0 1 2 3 4 5 M 1 1 2 3 4 5 C 2 1 2 3 4 5 C 3 2 2 3 4 5 O 4 3 2 3 4 5 H 5 4 3 2 3 4 N 6 5 4 3 3 3 T1 T2 Cost M - 1 C - 1 C C 0 O O 0 H H 0 - E 1 N N 0 T1 T2 Cost M - 1 C C 0 C - 1 O O 0 H H 0 - E 1 N N 0
  • 9. Practice G O O D G O D G O D TRY TRY G O O D 0 1 2 3 4 G 1 0 1 2 3 O 2 1 0 1 2 D 3 2 1 1 1
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 17. Left most descendent Function l(x) give as the most left descendent of the node x
  • 18. Key roots x is a key root if:
  • 19.
  • 20. Mappings M H S I I S S B Domain: Range:  Deleted: in the domain: Changed Exact match Inserted: in the range
  • 21. Mappings M H S I I S S B Domain: Range:  Transformation = { 1,2 } , { 2,  } , { 3,1 } , { 4,4 } , {  ,3 } Note: this is NOT a tai map. 1 1 2 2 3 3 4 4
  • 22. The sets TR: Transformations M: Map C: change Cost =1 EX: exact match Cost = 0 I: Insertion Cost = 1 D: deletion Cost= 1 TR = EX + C + I + D M = EX + C M H S I I S S B Domain: Range:  1 1 2 2 3 3 4 4
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. Practice: prove the “triangle inequality” Prove:  (M3)   (M1)+  (M2) | M3 = M1*M2 Clue:  (M0) = |C0|+|I0|+|D0| TR: Transformations M: Map C: change Cost =1 EX: exact match Cost = 0 I: Insertion Cost = 1 D: deletion Cost= 1 TR: Transformations M: Map C: change Cost =1 EX: exact match Cost = 0 I: Insertion Cost = 1 D: deletion Cost= 1
  • 31. Practice All possible combinations of the set m1 and m2 in m3 gives same or less cost combined, than alone. SET1 COST SET2 COST SET3 COST DIFF EX 0 EX 0 EX 0 0 EX 0 C 1 C 1 0 EX 0 D 1 D 1 0 C 1 EX 0 C 1 0 C 1 C 1 C/EX 1/0 -1/-2 C 1 D 1 D 1 -1 I 1 EX 0 I 1 0 I 1 C 1 I 1 -1 I 1 D 1 None 0 -2 D 1 None 0 D 1 0 D 1 I 1 C/EX 1/0 -1/-2 None 0 I 1 I 1 0
  • 32.
  • 33.
  • 34.
  • 35. Tree distance  ( , )+  ( )  ( , )= min  ( , )+  ( )  ( , )+  ( ) delete add change
  • 36. Forest distance  ( , ) = min  ( , )+  ( )  ( , )+  ( ) delete add  ( , )+  ( , )
  • 37. Why this is not allowed? Clue: check tai mapping restrictions  ( , )+  ( )  ( , ) = min  ( , )+  ( )  ( , )+  ( ) delete add change
  • 38.  ( , )+  ( )  ( , )= change
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.  
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74. THANKS FOR YOUR ATENTION