開始使用免費開始

分解中的資訊遺失

你可能會好奇,欄數少很多的因子,怎麼能在不遺失資訊的情況下,概括更大的 DataFrame。事實上做不到——我們建立的因子通常只是對資料的近似,難免會有部分資訊遺失。這代表預測值未必精確相等,但應該會足夠接近而具有實用性。

在這個練習中,你會查看上一題相同、尚未分解前的原始 DataFrame(已載入為 original_df),並把它和兩個因子 user_matrix 與 item_matrix 的乘積進行比較。

本練習屬於課程

用 Python 建立推薦引擎

檢視課程

練習說明

  • 計算 user_matrix 和 item_matrix 的點積,並將結果儲存為 predictions_df。

動手互動練習

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

import numpy as np

# Multiply the user and item matrices
predictions_df = ____.____(____, ____)
# Inspect the recreated DataFrame
print(predictions_df)

# Inspect the original DataFrame and compare
print(original_df)
編輯並執行程式碼