Session Ready
Exercise

Optimizing flights linear regression

Up until now you've been using the default hyper-parameters when building your models. In this exercise you'll use cross validation to choose an optimal (or close to optimal) set of model hyper-parameters.

The following have already been created:

  • regression — a LinearRegression object
  • pipeline — a pipeline with string indexer, one-hot encoder, vector assembler and linear regression and
  • evaluator — a RegressionEvaluator object.
Instructions
100 XP
  • Create a parameter grid builder.
  • Add grids for with regression.regParam (values 0.01, 0.1, 1.0, and 10.0) and regression.elasticNetParam (values 0.0, 0.5, and 1.0).
  • Build the grid.
  • Create a cross validator, specifying five folds.