Term Frequency › Raw Term Frequency

Michael BrenndoerferMarch 30, 20252 min read
Language AI HandbookAll chapters
Part 2 of 67Classical Text Representations
Chapter 11Term Frequency › Raw Term Frequency
Reading section 3 of 17 · Raw Term Frequency · 2 minSection 3 of 17 · 2 min

Book contents

Section 3 of 17 · 2 min read

Term Frequency › Raw Term FrequencyOne section · Sections in this chapter3 / 17 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

The simplest possible definition of term frequency uses the raw count directly. Raw TF answers the question: "How many times does this term appear in this document?"

tfraw(t,d)=count(t,d)\text{tf}_{\text{raw}}(t, d) = \text{count}(t, d)

where:

  • tfraw(t,d)\text{tf}_{\text{raw}}(t, d): the raw term frequency weight for term tt in document dd
  • count(t,d)\text{count}(t, d): the number of times term tt appears in document dd

This is exactly what you get from the Bag of Words vectorizer: each entry in the document vector is the number of times the corresponding word appears in the document.

Raw counts are intuitive and fast to compute. They preserve the full information in the term occurrences, which means they can distinguish between a document that mentions "algorithm" twice and one that mentions it twenty times. For some applications, this direct proportionality is exactly what you want. Imagine counting how many times a legal document mentions a specific clause or how many times a customer review mentions "refund." In those cases, absolute counts are the signal.

When to use it: Raw counts are appropriate when your downstream task is insensitive to document length, or when all documents in your corpus are roughly the same length. They're also a natural fit when you want to weight by absolute frequency, such as counting how many times a specific keyword appears in a legal contract to flag potential issues, or when building features for a system where document length is itself a signal you want to preserve.

Limitation: As described above, raw counts suffer from length bias. They also allow very high-frequency terms to dominate the representation. The word "the" might appear 50 times in an essay, drowning out more meaningful terms that appear only a handful of times. Without normalization, your document vectors will be heavily influenced by stopwords and will conflate short focused documents with long discursive ones.