TF-IDF

Term frequency-inverse document frequency: evaluates how important a word is to a corpus of documents (01 Intro s.26).

= total docs in corpus; = number of docs in which appears. More weight to rare words, less weight to common words (domain-specific stopwords). The curve (s.26) shows growth is dampened.

Added context

A term in all documents gets .

Concept - Bag of Words | Concept - Stopword Removal

Appears in

In Naive Bayes (03 Text Classification, s.146-147)

Text features after preprocessing: word counts, frequencies / TF-IDF values, or binary indicators (s.146). Concept - Multinomial Naive Bayes accepts counts or TF-IDF values as input (s.147). See 03 Text Classification - Chunk 05 (s.121-150).

Worked example with cosine similarity (s.38-39) (01 Intro - Chunk 02 (s.31-48))

For d1 = “Saturn is the gas planet with rings.” (7 words) the TF-IDF vector starts : is/the occur in all 3 docs so weight 0; rarer terms (with, rings: 0.07; Jupiter, largest in d2: 0.08) get the highest weights. Combined with Concept - Cosine Similarity it is a commonly used combination for text clustering (Concept - Document Clustering): cos(d1,d2)=0.13, cos(d1,d3)=0.05, cos(d2,d3)=0.00.

From 02 Pre-processing s.67-68

with (note the “1+” here vs in 01 Intro). tf = word count scaled by an importance factor; idf looks at (documents containing ) and reverses the scaling; = number of documents (s.67). Intuition: importance grows with times a word appears, shrinks with number of documents containing it; “the”, “I”, “on”, “document” get a scale near zero (s.68). See 02 Pre-processing - Chunk 03 (s.61-90).