Bag of Words (BoW)

What Does Bag of Words Mean?

Bag of Words (BoW) is a natural language processing (NLP) strategy for converting a text document into numbers that can be used by a computer program. BoW is often implemented as a Python dictionary. Each key in the dictionary is set to a word, and each value is set to the number of times the word appears.

Advertisements

The BoW model is one of the most useful ways to convert text data for use by machine learning algorithms. In this context, text words are referred to as tokens and the entire process of representing a sentence as a bag of words vector (a string of numbers) is known as tokenization.

Techopedia Explains Bag of Words

BoW models are concerned with whether a known word occurs in a document and how many times it occurs — not the order in which it appears, nor its context. BoW plays an important role in natural language processing, information retrieval from documents and document classification.

How Bag of Words Works

BoW is used to extract feature sets from text during the data pre-processing phase. The strategy involves breaking a document down into a list of disparate words and noting how many times each word is used in the document.

The name ‘Bag of Words’ is thought to have been inspired by the popular word game, Scrabble. The value of each tile in a Scrabble bag was determined by how frequently a specific letter appeared on the front page of the New York Times in 1938.

Advertisements

Related Terms

Latest Analytics Terms

Related Reading

Margaret Rouse

Margaret Rouse is an award-winning technical writer and teacher known for her ability to explain complex technical subjects to a non-technical, business audience. Over the past twenty years her explanations have appeared on TechTarget websites and she's been cited as an authority in articles by the New York Times, Time Magazine, USA Today, ZDNet, PC Magazine and Discovery Magazine.Margaret's idea of a fun day is helping IT and business professionals learn to speak each other’s highly specialized languages. If you have a suggestion for a new definition or how to improve a technical explanation, please email Margaret or contact her…