TFIDF
Bag of Words counts how often a word appears. But the words that appear most are exactly the ones that tell you least. TFIDF is the fix.
1Three kinds of word
Plot how often words occur against how much they are worth and the picture splits into three bands:
| Band | How often it occurs | How much value it has |
|---|---|---|
| Stop words | The highest occurrence, in almost all documents | Negligible — they say nothing about the corpus |
| Frequent words | Adequate occurrence | Some value — these mostly talk about the document's subject |
| Rare or valuable words | The least | The most value of all |
2The three terms
that is, TFIDF(W) = TF(W) × log(N / DF(W))
with log to the base 10. You do not need to work the log out by hand — use the log button on a calculator.
3Watch a stop word collapse
Four short documents. Switch between the two measures and watch what happens to the most common word in the corpus.
Four documents, ten unique words. Switch between the two measures and watch one row collapse.
On frequency alone, the looks like the most important word in the corpus. It tells you nothing about any of these documents.
That is the whole mechanism, and it is worth being able to state in one line.
A word that everyone uses tells you nothing
4What the values mean
- Words that occur in all the documents with high term frequencies have the lowest values, and are considered stop words.
- For a high TFIDF value, a word needs a high term frequency but a low document frequency — it is important to one document but is not common across all of them.
- These values tell the computer which words to consider. The higher the value, the more important the word is to the corpus.
5From the board papers
(A) Stop word (B) Rare word (C) Frequent word (D) Valuable wordCBSE board exam 2025
▶Show the answer
(A) Stop word. Highest occurrence, negligible value — and their TFIDF works out to exactly 0, since log(4/4) = log(1) = 0.
(a) Stop word (b) Rare word (c) Frequent word (d) Filter wordCBSE sample papers 2023–24 and 2024–25
▶Show the answer
(b) Rare word — also called a valuable word. It occurs the least and carries the most value. Its IDF is 4/1 = 4, so log(4) ≈ 0.602, the highest score available in a 4-document corpus.
▶Show the answer
‘and’: IDF = 10/10 = 1, and log(1) = 0. Its TFIDF value is 0 however often it appears — it is a stop word.
‘pollution’: IDF = 10/3 = 3.333, and log(3.333) ≈ 0.522. It has considerable value in the corpus.
As the document frequency rises, the value of the word falls.
6Check yourself
What does TFIDF stand for?
A word appears in every document of the corpus. Its TFIDF value is:
For a word to have a high TFIDF value it needs:
Term frequency can be read straight off which table?