Feature engineering on categorical variables with Spark
In this chapter, I have demonstrated how to build an ad click predictor that learns from massive click logs using Spark. Thus far, we have been using one-hot encoding to employ categorical inputs. In this section, we will talk about two popular feature engineering techniques: feature hashing and feature interaction.
Feature hashing is an alternative to one-hot encoding, while feature interaction is a variant of one-hot encoding. Feature engineering means generating new features based on domain knowledge or defined rules, in order to improve the learning performance achieved with the existing feature space.
Hashing categorical features
In machine learning, feature hashing (also called the hashing trick) is an efficient way to encode categorical features. It is based on hashing functions in computer science, which map data of variable sizes to data of a fixed (and usually smaller) size. It...