LoslegenKostenlos loslegen

RMSE as ALS alternates

As you know, ALS will alternate between the two factor matrices, adjusting their values each time to iteratively come closer and closer to approximating the original ratings matrix. This exercise is intended to illustrate this to you.

Matrix T is a ratings matrix, and matrices F1, F2, F3, F4, F5, and F6 are the respective products of ALS after iterating 2, 3, 4, 5, and 6 times respectively. Follow the instructions below to see how the RMSE changes as ALS iterates.

Diese Übung ist Teil des Kurses

Building Recommendation Engines with PySpark

Kurs anzeigen

Anleitung zur Übung

  • Use getRMSE(pred_matrix, actual_matrix) to calculate the RMSE of F1.
  • Put F2, F3, F4, F5, and F6 into one list called Fs.
  • Complete the getRMSEs(listOfPredMatrices, actualValues) function to calculate the RMSE of each matrix in the Fs list.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Use getRMSE(preds, actuals) to calculate the RMSE of matrices T and F1.
getRMSE(____, ____)

# Create list of F2, F3, F4, F5, and F6
Fs = [____, ____, ____, ____, ____]

# Calculate RMSE for F2, F3, F4, F5, and F6.
getRMSEs(____, ____)
Code bearbeiten und ausführen