TF-IDF stands for term frequency and inverse document frequency. It evaluates the importance of a word to a document in a corpus, which increases with the number of times it appears in the document but is offset by its frequency in the corpus. More precisely, for TF, we define
tf(term∣document)=total number of words in "document"the number of times "term" appears in "document"
For IDF, we define
idf(term)=1+log(the number of documents this term appears inthe total number of documents)
Now suppose we have a query. Let Q={t1,t2,...,tn} the set of different term in the query. We convert Q into a vector,