開始使用免費開始

ALS 交替時的 RMSE

如你所知,ALS 會在兩個因子矩陣之間交替,每次調整它們的數值,透過反覆運算逐步逼近原始的評分矩陣。本練習要讓你看到這個過程。

矩陣 T 是評分矩陣,而矩陣 F1F2F3F4F5F6 分別是 ALS 迭代 2、3、4、5、6 次後得到的結果。依照下方說明,觀察 ALS 在迭代時 RMSE 的變化。

本練習屬於課程

使用 PySpark 打造推薦引擎

檢視課程

練習說明

  • 使用 getRMSE(pred_matrix, actual_matrix) 計算 F1 的 RMSE。
  • F2F3F4F5F6 放入一個名為 Fs 的 list。
  • 完成 getRMSEs(listOfPredMatrices, actualValues) 函式,以計算 Fs 清單中每個矩陣的 RMSE。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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(____, ____)
編輯並執行程式碼