AIExplainer
Machine Learning Intermediate 2 min read

What is edit distance?

The minimum number of operations required to change one string into another

Edit distance is a measure of how similar or different two strings of text are. It calculates the minimum number of operations, such as insertions, deletions, or substitutions, needed to transform one string into another.

Think of edit distance like the number of steps needed to get from one city to another. Just as you might take different routes to get to your destination, edit distance finds the shortest 'route' to change one string into another.

For example, the edit distance between 'kitten' and 'sitting' is 3, because you need to substitute 's' for 'k', substitute 'i' for 'e', and append 'g' to get from 'kitten' to 'sitting'.

Edit distance is used in various applications, including spell-checking, speech recognition, and DNA sequencing, to compare and measure the similarity between strings of text or sequences of data.

One common misconception is that edit distance only measures the difference in length between two strings. However, it also takes into account the actual characters and their positions in the strings.

The concept of edit distance was first introduced in the 1960s by Vladimir Levenshtein, a Russian mathematician, and is also known as the Levenshtein distance.

Levenshtein distance string distance sequence distance

Three products for different needs — explore what’s relevant to you.