Nearest-neighbors is more versatile than just dealing with numbers. As long as we have a way to measure distances between features, we can apply the nearest-neighbors algorithm. In this recipe, we will introduce how to measure text distances with TensorFlow.
Working with text based distances
Getting ready
In this recipe, we will illustrate how to use TensorFlow's text distance metric, the Levenshtein distance (the edit distance), between strings. This will be important later in this chapter, as we expand the nearest-neighbor methods to include features with text.
The Levenshtein distance is the minimal number of edits to get from one string to another string. The allowed edits are inserting a character, deleting a character...