Extracting the right features from your data
The field of Natural Language Processing (NLP) covers a wide range of techniques to work with text, from text processing and feature extraction through to modeling and machine learning. In this chapter, we will focus on two feature extraction techniques available within Spark MLlib and Spark ML: the term frequency-inverse document frequency (tf-idf) term weighting scheme and feature hashing.
Working through an example of tf-idf, we will also explore the ways in which processing, tokenization, and filtering during feature extraction can help reduce the dimensionality of our input data as well as improve the information content and usefulness of the features we extract.
Term weighting schemes
In Chapter 4, Obtaining, Processing, and Preparing Data with Spark, we looked at vector representation, where text features are mapped to a simple binary vector called the bag-of-words model. Another representation used commonly in practice is called Term Frequency...