Skip to content

Bag of Words

A way to represent text as a set of words with their frequencies, ignoring the order. "The cat ate the mouse" and "the mouse ate the cat" would give the same bag.

How It Is Built

  1. Collect a dictionary of all words.
  2. For each document, count how many times each word appears.
  3. Obtain a frequency vector.

Pros and Cons

  • Pros: simple, fast, understandable.
  • Cons: loses word order and meaning; common words like "and" dominate (they are removed as stop-words).

Further Development

TF-IDF weights frequencies by importance, while embeddings move towards meaning.

See Also

← All Terms