The bag of words model (BoW model) is a reduced and simplified representation of a text document from selected parts of the text, based on specific criteria, such as word frequency.
In a BoW a body of text, such as a sentence or a document, is thought of as a bag of words. Lists of words are created in the BoW process. These words aren’t sentences, as grammar is ignored in their collection and construction. The words are often representative of the content of a sentence. While grammar and order of appearance are ignored, multiplicity is counted and may be used later to determine the focus points of the document. The frequency of each term is tallied while the semantic relationships are ignored.
BoW may use multisets of documents or treat sentences as different documents tallying for each:
Jill is fond of Jack but Jack is fond of his neighbor’s dog, Sam. Sam is more fond of the peanut butter sandwiches Jack always has.
Jill is fond of Jack but his neighbor’s dog Sam more the peanut butter sandwiches always has
D1: 1 2 2 2 1 1 1 1 1 1 0 0 0 0 0 0 0
D2: 0 1 2 1 0 0 0 0 0 1 1 1 1 1 1 1 1
Similarly to BoW, bag of features (BoF) can be applied to other information such as images. BoF analyzes an image's pixel data such as the level from 0-256 for each pixels red, blue, green and luminance values. By understanding how an image's pixels are positioned and the relative values of each pixel, an algorithm might be used to pick out patterns or textures.