
PySpark Cookbook
By :

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
.
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:
Binarizer
is a method that, given a threshold, transforms a continuous numerical feature into a binary one.Bucketizer
, similarly to Binarizer
, uses a list of thresholds to transform a continuous numerical variable into a discrete one (with as many levels...