On Practical Accuracy of Edit Distance Approximation Algorithms

Hiroyuki Hanada, Mineichi Kudo, Atsuyoshi NakamuraarXiv 2017

Abstract

Calculating the exact edit distance between long strings is computationally expensive, typically requiring $O(n^2)$ time. While numerous approximation algorithms offer significant speedups, their practical accuracy is often obscured by asymptotic "Big-O" notation. This paper evaluates six leading approximation algorithms by refining their theoretical distortion bounds with constant factors and benchmarking them on real-world genomic and protein datasets.

Introduction

The edit distance, or Levenshtein distance, is a fundamental metric for string similarity in bioinformatics and text mining. However, its quadratic time complexity becomes a prohibitive bottleneck for large-scale datasets. To address this, various linear or near-linear time approximation algorithms have been proposed. The accuracy of these approximations is measured by distortion—the ratio between the approximated distance and the true distance.

Historically, literature has focused on asymptotic distortion bounds (e.g., $O(\log n)$), which can overlook constant factors that significantly impact real-world performance. This study aims to bridge the gap between theory and practice by identifying which algorithms provide the most accurate results in practical scenarios.

Methodology

The researchers employed a two-fold approach to evaluate the algorithms:

  1. Theoretical Refinement: They re-analyzed six prominent algorithms to derive exact constant coefficients for their distortion bounds, providing a more granular view than standard Big-O notation.
  2. Experimental Benchmarking: The algorithms were tested across varying string lengths ($n$), alphabet sizes ($|\Sigma|$), and edit counts ($e$).

The algorithms were categorized into four distinct groups:

  • q-gram-based: [Bar-Yossef 2004], [Sokolov 2007] (counting short substring occurrences).
  • Ulam-metric-based: [Charikar 2006], [Andoni 2009] (designed for strings with distinct characters).
  • Restricted alignment: [Andoni 2010] (utilizing q-gram-wise alignment).
  • Shrinking algorithms: [Batu 2006] (merging characters to reduce string length).
Figure 1: The concept of distortion $K$ over a set $S$, illustrating the relationship between true distance $f(z)$ and approximated distance $\tilde{f}(z)$.

Datasets

To ensure robust findings, the study utilized three data types:

  • Artificial Random Data: Strings with controlled lengths ($n=100$ to $1000$) and alphabet sizes ($|\Sigma|=4$ or $20$) to probe edge cases.
  • DDBJ (DNA Data Bank of Japan): Real DNA sequences with a small alphabet ($|\Sigma| \approx 4$).
  • UniProt (Universal Protein Resource): Real amino acid sequences with a larger alphabet ($|\Sigma| \approx 25$).

Key Insights

The "Big-O" Gap

Theoretical superiority does not always translate to practical performance. For instance, while [Batu 2006] has the best asymptotic distortion (sub-logarithmic), it only begins to outperform other methods theoretically when string lengths exceed 300 characters.

Alphabet Sensitivity

The size of the alphabet is a critical performance factor. q-gram-based methods ([Bar-Yossef] and [Sokolov]) performed significantly better on protein data (large alphabet) than on DNA data (small alphabet). In larger alphabets, q-grams are more likely to be unique, which minimizes collisions and improves accuracy.

Worst-Case vs. Reality

A major finding was that experimental distortion was often 10 times lower than the refined theoretical worst-case bounds. This indicates that these algorithms are far more reliable for real-world data than theoretical analysis might suggest.

Figure 2: Experimental observation of distortion across different string lengths ($n$) and distance thresholds ($\theta$).

Results

  • Top Performer: [Andoni 2010] was the most consistent performer across most datasets, especially for real-world genomic and protein sequences.
  • Theoretical Leader: [Batu 2006] remains the theoretical champion for very long strings ($n \ge 300$).
  • Contextual Strengths:
  • For large alphabets with few edits, [Charikar 2006] and [Bar-Yossef 2004] were highly competitive.
  • [Sokolov 2007] and [Andoni 2009] generally exhibited higher distortion.
  • Practical Distortion: In real-world tests, distortion typically ranged between 10 and 100 for strings up to 10,000 characters.

Conclusion and Future Work

While this study clarifies the accuracy of various approximations, a trade-off between accuracy and speed remains. Algorithms like [Andoni 2010] can still be computationally intensive without proper pruning. Future research should focus on the wall-clock execution time versus accuracy trade-off and the challenges of parameter tuning in "blind" applications. Practitioners are advised to select algorithms based on their specific data characteristics, such as using q-gram methods for proteins and restricted alignment for DNA.

Summary updated

Abstract

The edit distance is a basic string similarity measure used in many applications such as text mining, signal processing, bioinformatics, and so on. However, the computational cost can be a problem when we repeat many distance calculations as seen in real-life searching situations. A promising solution to cope with the problem is to approximate the edit distance by another distance with a lower computational cost. There are, indeed, many distances have been proposed for approximating the edit distance. However, their approximation accuracies are evaluated only theoretically: many of them are evaluated only with big-oh (asymptotic) notations, and without experimental analysis. Therefore, it is beneficial to know their actual performance in real applications. In this study we compared existing six approximation distances in two approaches: (i) we refined their theoretical approximation accuracy by calculating up to the constant coefficients, and (ii) we conducted some experiments, in one artificial and two real-life data sets, to reveal under which situations they perform best. As a result we obtained the following results: [Batu 2006] is the best theoretically and [Andoni 2010] experimentally. Theoretical considerations show that [Batu 2006] is the best if the string length n is large enough (n >= 300). [Andoni 2010] is experimentally the best for most data sets and theoretically the second best. [Bar-Yossef 2004], [Charikar 2006] and [Sokolov 2007], despite their middle-level theoretical performance, are experimentally as good as [Andoni 2010] for pairs of strings with large alphabet size.
BibTeX
@misc{hanada2017practical,
  author = {Hiroyuki Hanada and Mineichi Kudo and Atsuyoshi Nakamura},
  title = {{On Practical Accuracy of Edit Distance Approximation Algorithms}},
  year = {2017},
  eprint = {1701.06134},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1701.06134},
}
Figure