Nowadays machine learning and big data are the hottest terminology in the Internet industry, Viktor Mayer in Big data mentions that we need to be promiscuous rather than precise, and statistical significance gives us more space under big data. Since it is not too much to pursue accuracy, it is less important that the string is completely histograms, and the similarity of strings will play a more important role. Similarity evaluation is also widely used in information retrieval systems, so we can use those methods to evaluate the similarity of strings, in other words, to find the distance between the strings.
1. Euclidean similarity
Suppose there is a string x and Y, after the word participle (Chinese) to get the word of the string, and to count the number of words are recorded as: [X1,x2,...,xn];[y1,y2,...,yn].
D (X, Y) = sqrt (sum (xi-yi) 2)
We can also add a weight to each word based on the importance of the word, such as: if we have a text set, we can calculate the weight of the word according to TF-IDF.
2. Similarity of Jaccard
Consider the word in string X as the set S, and the words in Y as the set Y,jsccard (x, y) = | s∩y|/| sυy|.
We also have the flexibility to set the elements in the collection, which can be used as the collection element, or as a set of elements of the string's substrings (I<=LEN<=J).
3. Cosine similarity
The vector of the string x and Y is obtained by the same method as the Euclidean similarity, then the cosine of the vector is computed, and the cosine similarity corresponds to the angle between the string x and the y vector, and the smaller the angle, the more similar the two strings are. Wu in the beauty of mathematics describes how to use the cosine similarity to the news text classification, interested students Baidu.
4. Editing distance
Edit distance refers to the number of steps by inserting/deleting x into Y, there is a lot of information about editing distance calculation algorithm on the net, interested students please own Baidu.
5. Hamming distance
Hamming distance refers to the number of different components in the two vectors, the vector of which each component is 0/1 based on the string, then the Hamming distance can be calculated.
6. LCS
It is also a good choice to measure the similarity of strings with the longest common subsequence length or the longest common substring length.
Summary, the above-mentioned string similarity evaluation method does not necessarily be able to accurately evaluate the similarity when used alone, but it should be a good choice if it is a one-dimensional eigenvalue of machine learning training concentration, as the opening remarks, the big data age does not pursue precision, but we need more dimensions to characterize the characteristics of things.
Evaluation of string similarity