Created
October 26, 2020 15:35
-
-
Save naiborhujosua/232f07e4849e945a5aec0e61325a6e00 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For loop will automatically create and store ALS models | |
for r in ranks: | |
for mi in maxIters: | |
for rp in regParams: | |
for a in alphas: | |
model_list.append(ALS(userCol= "userId", itemCol= "songId", ratingCol= "num_plays", rank = r, maxIter = mi, regParam = rp, alpha = a, coldStartStrategy="drop", nonnegative = True, implicitPrefs = True)) | |
# Print the model list, and the length of model_list | |
print (model_list, "Length of model_list: ", len(model_list)) | |
# Validate | |
len(model_list) == (len(ranks)*len(maxIters)*len(regParams)*len(alphas)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.