Bag of words representation
The scikit-learn has a handy module called feature_extraction that allows us to, as the name suggests, extract features for data such as text in a format supported by machine learning algorithms. This module has methods for us to utilize when working with text.
Going forward, we may refer to our text data as a corpus, specifically meaning an aggregate of text content or documents.
The most common method to transform a corpus into a numerical representation, a process known as vectorization, is through a method called bag-of-words. The basic idea behind the bag of words approach is that documents are described by word occurrences while completely ignoring the positioning of words in the document. In its simplest ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access