1. Learn
  2. /
  3. Courses
  4. /
  5. Building Recommendation Engines with PySpark

Exercise

Build implicit models

Now that you have all of your hyperparameter values specified, let's have Spark build enough models to test each combination. To facilitate this, a for loop is provided here. Follow the instructions below to automatically create these ALS models. In subsequent exercises you will run these models on test datasets to see which one performs the best.

The ALS algorithm is already imported for you. The lists you created in the last exercise (ranks, maxIters, regParams, alphas) have been created for you.

Instructions

100 XP
  • An empty list called model_list is provided here. The for loop will create a model for each combination of hyperparameters it is given and put it into model_list.
  • Complete the for loop by referencing the contents of each list where r represents the elements of the ranks list, mi represents the elements of the maxIters list, rp represents the elements of the regParams list and a represents the elements of the alphas list.
  • Print len(model_list) as well as model_list to ensure that each model was created. The length should be equal to the product of all the lengths of each hyperparameter list above. You can run the additional validation provided to be sure.