Complete the code to create a VectorAssembler that combines columns 'height' and 'weight' into a new column 'features'.
from pyspark.ml.feature import VectorAssembler assembler = VectorAssembler(inputCols=['height', 'weight'], outputCol=[1])
The output column name for the assembled features is usually called 'features'.
Complete the code to fit a StandardScaler on the 'features' column and output scaled features to 'scaledFeatures'.
from pyspark.ml.feature import StandardScaler scaler = StandardScaler(inputCol='features', outputCol=[1], withMean=True, withStd=True) scalerModel = scaler.fit(df)
The output column for scaled features is often named 'scaledFeatures' to clearly indicate the transformation.
Fix the error in the code to transform the DataFrame using the fitted scaler model.
scaledData = scalerModel.[1](df)The correct method to apply the scaler model to the DataFrame is 'transform'.
Fill both blanks to create a VectorAssembler and then transform the DataFrame to add the features column.
assembler = VectorAssembler(inputCols=[1], outputCol='features') assembledData = assembler.[2](df)
The input columns should be ['height', 'weight'] and the method to apply the assembler is 'transform'.
Fill all three blanks to create a StandardScaler, fit it on the assembled data, and transform it to get scaled features.
scaler = StandardScaler(inputCol=[1], outputCol=[2], withMean=True, withStd=True) scalerModel = scaler.[3](assembledData) scaledData = scalerModel.transform(assembledData)
The input column is 'features', output column is 'scaledFeatures', and the scaler model is created by calling 'fit' on the assembled data.
