TF-IDF of one word
A corpus has 1,000 documents; "transformer" appears in 10 of them. In a 100-word document it appears 5 times. Using log base 10, what is its TF-IDF in that document?
Show the working
- TF5 ÷ 100 = 0.05
- IDFlog₁₀(1000 ÷ 10) = log₁₀ 100 = 2
- Multiply0.05 × 2 = 0.1
TF-IDF = 0.1
Trap: a word like "the" in all 1,000 docs gets IDF = log 1 = 0, however often it appears.