Example of Bag-of-Words Model
•Data collected:
•It was the best of times,
it was the worst of times,
it was the age of wisdom,
it was the age of foolishness
•Design the Vocabulary
–“it”
–“was”
–“the”
–“best”
–“of”
–“times”
–“worst”
–“age”
–“wisdom”
–“foolishness”
•Create Document Vectors
•Vocabulary: “it” “was” “the” “best”
“of” “times” “worst” “age” “wisdom”
“foolishness”
•Scores:
•"it was the best of times"
–[1, 1, 1, 1, 1, 1, 0, 0, 0, 0]
• “it was the worst of times"
– [1, 1, 1, 0, 1, 1, 1, 0, 0, 0]
•"it was the age of wisdom"
– [1, 1, 1, 0, 1, 0, 0, 1, 1, 0]
•"it was the age of foolishness"
– [1, 1, 1, 0, 1, 0, 0, 1, 0, 1]