The Transformer
class, introduced in Spark 1.3, transforms one dataset into another by normally appending one or more columns to the existing DataFrame. Transformers are an abstraction around methods that actually transform features; the abstraction also includes trained machine learning models (as we will see in the following recipes).
In this recipe, we will introduce two Transformers: Bucketizer
and VectorAssembler
.
Note
We will not be introducing all the Transformers; throughout the rest of this chapter, the most useful ones will show up. For the rest, the Spark documentation is a good place to learn what they do and how to use them.
Here is a list of all of the Transformers that convert one feature into another: