Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

i have a list of text files and i know that these texts belong to a group, by using this group of text files (i.e this is my sample set) i'd like to calculate Jaccard index and Edit distance for each text file that are not in the sample set. By doing so i'd like to generate two features of each text file which are the similarity/diversity of each file from the sample set of text files. After constructing my dataset, classification will be used.

how can i achieve this? Problem arises when i try to calculate Jaccard index and Edit distance for each text file. i'm not sure i should calculate the Jaccard index and Edit distance for each text in sample set and take the average of them and use these as a feature, this can be computationally inefficient.

P.S: my reputation is too low that i couldn't create the tags of jaccard-index, edit-distance,similarity and divergence

share|improve this question
add comment

2 Answers

You may want to consider cosine similarity and the single linkage clustering algorithm.

share|improve this answer
add comment

Surely your sample set contains the correct classification for each sample in the form $\{x_{i},y_{i}\}$, with $x_{i}$ as a text document and $y_{i}$ as its classification.

Therefore, one approach you may want to explore is to determine a set of important words for your data set. Let's suppose you choose 100 words. Then you can create a list of 0's and 1's for each document in your sample set in order to create a $N \times M$ matrix where $N$ is the number of documents and $M$ the number of important words (in this case 100). Assign $0$ in the appropriate column to the document whenever that word doesn't appear in that document and $1$ otherwise.

Now you compare your test document to each sample document and calculate a Jaccard coefficient. Finally, assign the class of the sample document to the test document for which the Jaccard coefficient is closest to $1$. It seems to me that is the simplest equivalent to the KNN algorithm (with $K=1$).

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.